• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
setState has no effect on an NSButton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

setState has no effect on an NSButton


  • Subject: setState has no effect on an NSButton
  • From: Martin Batholdy <email@hidden>
  • Date: Tue, 10 May 2011 03:19:48 +0200

Hi,

I have a preference window with four NSButtons that are all connected to a method and an IBOutlet:

IBOutlet NSButton *buttonA;
IBOutlet NSButton *buttonB;
IBOutlet NSButton *buttonC;
IBOutlet NSButton *buttonD;
NSUserDefaults *prefs;


Now I would like to set the state of these buttons according to some UserDefaults:

-(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]; }
}


The code is exactly the same. I checked the connections in the interface builder twice.
There is no problem with getting the NSUserDefaults values.

But still, only the state of button A and B change according to the st-value.

On button B and C  setState: seems to have no effect at all.
Whatever I send to buttonB and buttonC nothing changes the appearance of this buttons in the window.

The code is identical.
There is nothing wrong with the plist and I don`t see any differences in the connections in the IBuilder...

When I debug this code I see that buttonA and buttonB have an address.
But buttonC and buttonD seems to have no address (0x0) ...


what could possibly be the problem here ...?


 _______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: setState has no effect on an NSButton
      • From: Graham Cox <email@hidden>
    • Re: setState has no effect on an NSButton
      • From: Quincey Morris <email@hidden>
    • Re: setState has no effect on an NSButton
      • From: Howard Siegel <email@hidden>
  • Prev by Date: Re: superview
  • Next by Date: Re: setState has no effect on an NSButton
  • Previous by thread: [ANN] NanoStore 2.0 is now available
  • Next by thread: Re: setState has no effect on an NSButton
  • Index(es):
    • Date
    • Thread