Skip to content

Instantly share code, notes, and snippets.

@feighter09
Created October 25, 2016 05:07
Show Gist options
  • Save feighter09/bbebafaf6690056ac4733cc2286355f2 to your computer and use it in GitHub Desktop.
Save feighter09/bbebafaf6690056ac4733cc2286355f2 to your computer and use it in GitHub Desktop.
let defaults = Defaults()
let hasLoggedIn = true
defaults.save(true, forKey: .LoggedIn)
defaults.save(false, forKey: .NotificationsEnabled)
let regularOrder = Order(item: "Cold Brew", size: .Large)
let alternateOrder = Order(item: "Latte", size: .Small)
defaults.save(regularOrder)
defaults.save(alternateOrder, forKey: .Alternate)
class Defaults {
func save<T: DefaultConvertible>(toSave: T, forKey key: T.Key = .Default) { ... }
func fetch<T: DefaultConvertible>(type: T.Type, forKey key: T.Key = .Default) -> T? { ... }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment