在Resources组的Settings.bundle文件中,到目前为止,我只有一个PSGroupSpecifier,并且在PSMultiValueSpecifier中有这个XML代码:
<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>
在AppDelegate的didFinishLaunchingWithOptions方法中我得到了值,但是firstDayOfWeek总是返回nil值,你能看到代码中的任何错误吗?
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *firstDayOfWeek = [defaults objectForKey:@"firstDayOfWeek"];
NSLog(@"FIRST DAY OF WEEK: %@", firstDayOfWeek);
答案 0 :(得分:1)
firstDayOfWeek
没有任何密钥。
“firstDayOfWeek”是键Key
的对象。
objectForKey
的参数字符串必须是plist <key>yourKey</key>
尝试:
<key>firstDayOfWeek</key>
<string>DefaultValue</string>