views:

24

answers:

1

I've got a weird one when I test on the iPhone... I have a settings.bundle that has a Boolean for background_sounds which is set to YES by default. The problem is, when the app loads first time, the background_sounds pref seems to be set to NO when checked. I've tried synchronizing NSUserDefaults and everything, but the only way of making it detect the background_sounds setting, is to go to the Settings page for the app, don't touch anything and then go back to the app... Then the sounds start playing again fine.

Any ideas? Is there a bug in the settings bundle or is it just me?? Thanks!

EDIT: I can acatually get it to read the preferences from the settings bundle, if I use NSUserDefaults in the correct way. It's just that I have to physically OPEN the settings panel on the iPhone FIRST before they are noticed in the app. Makes no sense...

+2  A: 
[[NSUserDefaults standardUserDefaults] registerDefaults:<dictionary>];

Are you registering your preferences value?

Manjunath
I'm setting them directly in my settings bundle. Do I need to also do what you mention in code?
Joe
okay so it looks like I'm not registering them... How do I reference my settings bundle? Do I have to load it into a dictionary first?
Joe
Sorry, I didn't realise that the app didn't actually read the settings bundle, but that the settings bundle wrote to the NSUserDefaults when the Settings app was opened. I think I get it now.
Joe