I made some preferences in my Settings.bundle that show up fine in the Settings app. However my settings always return nil when I read them back. I know I need to set a default value on first startup. But even after that and going to the settings menu (which should also set the default values) - when I read them back I always get nil.
Even when I set the default and read it back immediately I get nil!
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"YES" forKey:@"displaySunTimes"];
[defaults registerDefaults:appDefaults];
[defaults synchronize];
bool test =[defaults boolForKey:@"displaySunTimes"];
NSLog(@" Value %@", test);
Here's the beginning of my root.plist
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Display Sunrise / Sunset times for your location.</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Sunrise / Sunset</string>
<key>Key</key>
<string>displaySunTimes</string>
<key>DefaultValue</key>
<true/>
<key>TrueValue</key>
<string>YES</string>
<key>FalseValue</key>
<string>NO</string>
</dict>