I'm learning Cocoa and I'm up to a chapter regarding user preferences. I have a preference panel, whose nib is loaded and I read the user preferences file I've created. The preference panel consists of a checkbox and a color well. My user preference for the check box is returning false but yet the check box is checked when the preference panel is opened. In the NSLogs below print out that emptyDocument is false. The checkbox variable is an outlet for the PreferenceController class. Should I not be using setState to set or clear the checkbox? Below is the code snippet from PreferenceController.m:
- (id)initWithWindow:(NSWindow *)window
{
self = [super initWithWindow:window];
if (self) {
// Initialization code here.
[colorWell setColor: [self tableBackgroundColor]];
NSLog(@"emptyDocument will return %d", [self emptyDocument]);
[checkbox setState: [self emptyDocument]];
}
return self;
}
-(BOOL) emptyDocument
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"Returning %d for EmptyDocumentFlag", [defaults boolForKey:@"EmptyDocumentFlag"]);
return ([defaults boolForKey:@"EmptyDocumentFlag"]);
}