NSUserDefaults.standardUserDefaults().registerDefaults([
"SomeKey": 123,
"SomeArrayKey": [1, 2, 3, 4, 5]
])
I searched everywhere and couldn’t find an explanation of how to use registerDefaults(). Each asked how to set the default value The posts are all answered by “use registerDefaults()”. One small problem I encountered is that I don’t know how to use registerDefaults(). Can someone tell me exactly what code to write and where to put it. My question: I There are 5 values (Int) that need to have specific default values, but they can be changed by the user later. I checked the Xcode documentation, youtube and google, and couldn’t find the answer.
Simply pass a dictionary of key-value pairs:
NSUserDefaults.standardUserDefaults().registerDefaults([
"SomeKey": 123,
" SomeArrayKey": [1, 2, 3, 4, 5]
])