0

I'm having trouble with the user defaults, in the settings.bundle - root.plist I did the following entry:

enter image description here

When checking the value with:

BOOL showTutorial = [[[NSUserDefaults standardUserDefaults] objectForKey:@"SettingsShowTutorialOnLaunch"] boolValue];

I always getting a nil (Boolean NO) ... I've checked the identifier several times (no space at the end). It simply looks like I have no access to the UserDefaults - do I need to include a header or something to get access?

///// CORRECT ANSWER /////

I can't post an answer to my question as it was marked as duplicate already. The solution in my case was adding a registerDefaults:

    [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObject:@"YES" forKey:@"SettingsShowTutorialOnLaunch"]];

A very good tutorial is this one here: http://www.accella.net/knowledgebase/nsuserdefaults-some-pretty-good-practices/

Hecot
  • 89
  • 1
  • 11
  • 3
    Nothing from the settings bundle will appear in user defaults until the user runs the Settings app, goes to the page for your app, and changes a setting value. – rmaddy Dec 29 '16 at 20:08
  • A better answer is this one: [link](http://stackoverflow.com/questions/3759761/nsuserdefaults-problem/3759905) – Hecot Dec 30 '16 at 11:54

0 Answers0