When I'm setting up the default preferences for my app, I'm doing the following:
1) Reading Root.plist
from inside Settings.bundle
into a dictionary.
2) I test if a preference is set, and if not I'm registering my defaults dictionary via [NSUserDefaults standardUserDefaults] registerDefaults:]
Problem is, defaults registered with registerDefaults:
do not go to the persistent store, so if the user never changes their preferences I am reading my default preferences and registering them with NSUserDefaults
every time the app launches.
Instead of using registerDefaults:
I could use setValue:forKey:
and have my default setting go to the persistent store, bypassing the need to build & register a dictionary on each launch. However, Apple's documentation and sample code both point to registerDefaults:
.
So I'm trying to figure out when and why I should use registerDefaults:
and when/why I should use setValue:forKey:
instead?