Objective C: Read iPhone Preferences From Application
You can read preferences from your iPhone Application using the NSUserDefaults class from iPhone SDK.
Here is how you can read the delay value before the phone is starting to dial a number
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; delayBeforeDialing = [userDefaults floatForKey:@"delayBeforeDialing"];
The key, “delayBeforeDialing” in this example, needs to match the Key value in Root.plist.
There are different accessor methods depending on the type of variable you want to retrieve.
* arrayForKey
* boolForKey
* dataForKey
* dictionaryForKey
* floatForKey
* integerForKey
* objectForKey
* stringArrayForKey
* stringForKey
You don’t have to use a UI for your preferences. If you just want to conveniently store values associated with your application, that you can read back later, you can use the setter methods of NSUserDefaults.
[ad]
