Wednesday February 26, 2014

NSUserDefaults - Not Just For Persistent Settings

Ole Begemann just wrote a nice article on NSUserDefaults. It’s a good overview for newcomers to the platform, but it also highlighted a feature that I hadn’t considered before—domains.

Different configuration data can come from, or be stored, in different domains. What surprised me most was the NSArgumentDomain. It’s a volitile storage space (won’t be persisted across app runs) and is populated at app launch from command line parameters. Remember the strange command flag syntax to turn on Core Data’s SQLite debug logs? It sets the values in the NSArgumentDomain of the app’s NSUserDefaults.