views:

59

answers:

2

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?

A: 

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)

Jesse Naugher
That is the strange thing, I do have a DefaultValue on both.
RyanJM
oh im sorry i mustve skimmed over that part of the question here. see @stephens answer :)
Jesse Naugher
+2  A: 

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.

Stephen Furlani
This seems very silly to me, but alas that is the way Apple set things up. Thanks for pointing me in the right direction. http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/UserDefaults/Tasks/UsingDefaults.html%23//apple_ref/doc/uid/20000719-BAJFBAAH
RyanJM