Swift: Use NSUserDefaults to Store Persistence Data

From Hawk Wiki
Jump to: navigation, search
//Set data
NSUserDefaults.standardUserDefaults().setObject(["settingABC": false], forKey: "settingABC")
//Load Data
//func objectForKey(defaultName: String) -> AnyObject?
let settings = NSUserDefaults.standardUserDefaults().objectForKey("settingABC") as? [String: Bool]

To sync/update NSUserDefaults

NSUserDefaults.standardUserDefaults().synchronize()