Skip to content

Instantly share code, notes, and snippets.

@CaptainMalReynolds
Created February 25, 2016 21:05
Show Gist options
  • Save CaptainMalReynolds/489ce2648b524fcc7e8b to your computer and use it in GitHub Desktop.
Save CaptainMalReynolds/489ce2648b524fcc7e8b to your computer and use it in GitHub Desktop.
extension NSUserDefaults {
@nonobjc subscript(key: String) -> AnyObject? {
get {
return objectForKey(key)
}
set {
setObject(newValue, forKey: key)
}
}
@nonobjc subscript(key: String) -> Bool {
get {
return boolForKey(key)
}
set {
setBool(newValue, forKey: key)
}
}
// etc.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment