swilliams
swilliams

Reputation: 48890

NSUserDefaultsController keys return nil

I'm trying to implement a preference panel. I have an NSTextField that is bound to the Shared User Defaults Controller. The controller key is values and the Model Key Path is FolderPath.

Every time I try to access that value in code, the string is nil:

NSString *s = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] stringForKey:@"FolderPath"];
NSLog(s);

If I set a default dictionary, the value in the text box displays it properly, but it is still nil when retrieving it again.

    NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"foo"
                                                            forKey:@"FolderPath"];
    [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:appDefaults];

Am I missing something basic here?

Upvotes: 0

Views: 260

Answers (1)

Caleb
Caleb

Reputation: 124997

Do you ever send this user defaults controller a -save: message? If not, the values you set probably aren't being saved.

Upvotes: 1

Related Questions