On May 9, 2011, at 18:19, Martin Batholdy wrote:
> -(void)awakeFromNib {
>
> prefs = [NSUserDefaults standardUserDefaults];
>
> BOOL st = [prefs boolForKey:@"optionA"];
> if(st == YES) { [buttonA setState:NSOnState]; }
> else if(st == NO) { [buttonA setState:NSOffState]; }
>
> st = [prefs boolForKey:@"optionB"];
> if(st == YES) { [buttonB setState:NSOnState]; }
> else if(st == NO) { [buttonB setState:NSOffState]; }
>
> st = [prefs boolForKey:@"optionC"];
> if(st == YES) { [buttonC setState:NSOnState]; }
> else if(st == NO) { [buttonC setState:NSOffState]; }
>
> st = [prefs boolForKey:@"optionD"];
> if(st == YES) { [buttonD setState:NSOnState]; }
> else if(st == NO) { [buttonD setState:NSOffState]; }
> }
What is the class of the object containing this code, and how/when is this
object created? What class is the nib's File's Owner and how/when is that
object created, if different from the object containing the above code?
It could well be that your code is being invoked before all of the nib objects
are instantiated.
If the code's in a window controller, then you should do things like this in a
'windowDidLoad' override rather than 'awakeFromNib'.
If it's not in a window controller, then using a window controller is probably
your best strategy anyway. (There's almost no reason ever *not* to use a window
controller, and plenty of reasons to use one.)
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]