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?
Do you ever send this user defaults controller a -save:
message? If not, the values you set probably aren't being saved.
精彩评论