I have an iOS app, and as usual I store the user's preferences in NSUserDefaults
(or UserDefaults
as it is now called in Swift).
let ud = UserDefaults.standard
let foo = 123
ud.set(foo, forKey: "foo")
ud.integer(forKey: "foo")
Should key names be long, to defend against conflicts with the system, or are you safe just thinking about your application's names?
let fooKey = "com.mycompany.myapp.foo"
// or...
let fooKey = "foo"