April 2015
Intermediate to advanced
556 pages
17h 47m
English
You may have noticed that, aside from the scalar types, NSUserDefaults provides APIs for setting and getting objects. What kind of objects? Property list objects.
Property list objects are instances of the Objective-C classes NSDictionary, NSArray, NSString, and NSNumber. A plist data structure is composed entirely of these objects. As such you can store any data structure in NSUserDefaults that you like, as long as you can represent it as a plist. Since the Swift basic types are bridged to these types, you can store them without any issues. An example:
let userDefaults = NSUserDefaults.standardUserDefaults() let plistKey = "plist" if let plist: AnyObject = userDefaults.objectForKey(plistKey) { ...Read now
Unlock full access