Skip to content

Instantly share code, notes, and snippets.

View susanstevens's full-sized avatar

Susan Stevens susanstevens

View GitHub Profile
@susanstevens
susanstevens / Array+Combinations.swift
Last active March 29, 2020 21:06
Array Extension to Find All Possible Combinations of a Given Size in Swift
extension Array {
/**
Returns all possible combinations of `k` elements
- Parameter k: The size of the combinations to generate
- Returns: All possible combinations of `k` elements
*/
func combinations(k: Int) -> [[Element]] {
guard self.count > 0 && self.count >= k else { return [] }
@susanstevens
susanstevens / iphone-popover.md
Last active September 8, 2023 02:25
How to Create a Popover on iPhone

How to Create a Popover on iPhone

Storyboard set up

Add your view controllers in storyboard. In the Size Inspector, change the simulated size of the popover view controller to "Freeform". This doesn't change the popover's size when you run the app, but it does make it easier to lay out subviews correctly.

storyboard

When adding the segue between view controllers, select "Present as Popover".