I'm facing difficulty in fetching/saving setting bundle preference file by code. I'm a beginner.
I just need to fetch/save default value of key "VERSION 2" by code. I want to use the value of this key for my controllers to work. Thanks.This data is in:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//App开发者_JAVA技巧le//DTD PLIST 1.0//EN" "apple.com/DTDs/PropertyList-1.0.dtd">;
<plist version="1.0">
<dict>
<key>DefaultValue</key>
<string>Karachi</string>
<key>Key</key>
<string>version2</string>
<key>Title</key>
<string>VERSION</string>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
</dict>
</plist>
You do that by simply doing the following
NSUserDefaults *prefs - [NSUserDefaults standardUserDefaults]; //considering it's in the default settings.bundle
NSString *versionString = [prefs stringForKey:@"Key"];
You can use the following methods to get defaults
- arrayForKey
- boolForKey
- dataForKey
- dictionaryForKey
- floatForKey
- integerForKey
- objectForKey
- stringArrayForKey
- stringForKey
- doubleForKey
- URLForKey
精彩评论