ios - NSUserDefaults: Registering Defaults For Dictionary/Array values -


the setup

suppose app has nsdictionary store in userdefaults key somedict. dictionary looks this:

key1: value1 key2: value2 key3: value3 

when app launches, use [nsuserdefaults registerdefaults:] set initial value of somedict key dictionary above.

then, user changes preferences , dictionary gets updated looks this:

key1: somenewvalue1 key2: value2 key3: value3 

the key question

i ship new version of app. new version has somedict 4 initial values instead of three:

key1: value1 key2: value2 key3: value3 key4: somenewvalue 

the userdefaults domain contains value somedict, set when user ran older version of app. question this: -registerdefaults perform "deep" analysis of nsdictionary , nsarray values?

in other words, -registerdefaults going detect key4 missing old dictionary stored in somedict, or going say, "there's value somedict, we're done"?

i suspect latter. begs next question: there efficient approach handling sort of situation in cocoa, short of writing own "registerdefaults" method?

i don't know "deep" analysis, have updated apps (at app store, , personal use) changing user defaults dictionary, , far, seems work designed. have worked on assumption if new default value appears in updated dictionary, written without reversion of values changed user.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -