Reputation: 7068
The Settings Bundle is supposed to be a pretty straight forward thing, but for some reason I'm not getting it to work.
In my settings bundle's Root.plist I'm using a PSToggleSwitchSpecifier
and a PSTextFieldSpecifier
. Both have Type, Title, Key, and DefaultValue. And it shows up properly when looking at it in the Settings on the iPod Touch (and simulator). But I can't retrieve the values. They just come back NULL
.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
self.websiteURL = [defaults stringForKey:@"myBaseURL"];
The only way I get it to show any value is if I will go in to settings and change the values to something other than the default. Then when I go back to the app and it will work fine. How do I set it up so it doesn't require opening up the settings at all?
Upvotes: 2
Views: 5533
Reputation: 33
If someone is looking for a solution to register default user settings, you may check it out over here, worked really well for me.
Upvotes: 1
Reputation: 6866
Try this.
Returning nil
for a user default until the user sets it is default behavior, I think. You'll need to [defaults registerDefaults:];
to get a "default" value to show up.
Upvotes: 4
Reputation: 9820
you can add a key of DefaultValue to your plist for the desired key and set it to whatever you like (as long as it conforms to the type you specified for the key)
Upvotes: 0