Swift: Use NSUserDefaults to Store Persistence Data

From Hawk Wiki
Revision as of 04:04, 10 April 2015 by Hall (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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()