nil value reading settings.bundle
-
25-09-2019 - |
Question
In the Settings.bundle file in Resources group, so far, I have only a PSGroupSpecifier and inside a PSMultiValueSpecifier with this XML code:
<dict>
<key>Title</key>
<string>First day of week</string>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Key</key>
<string>firstDayOfWeek</string>
<key>DefaultValue</key>
<string>Sunday</string>
<key>Values</key>
<array>
<string>Sunday</string>
<string>Monday</string>
</array>
<key>Titles</key>
<array>
<string>Sunday</string>
<string>Monday</string>
</array>
</dict>
in the AppDelegate didFinishLaunchingWithOptions method I get the value, but firstDayOfWeek always returns nil value, can you see any mistake in the code?
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *firstDayOfWeek = [defaults objectForKey:@"firstDayOfWeek"];
NSLog(@"FIRST DAY OF WEEK: %@", firstDayOfWeek);
Solution
You don't have any key for firstDayOfWeek
.
"firstDayOfWeek" is the object for key Key
.
The argument string of objectForKey
must be a key in the plist <key>yourKey</key>
Try:
<key>firstDayOfWeek</key>
<string>DefaultValue</string>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow