PDA

View Full Version : NSButton question in cocoa




youngplayer
Jul 2, 2008, 01:48 AM
my codes:

IBOutlet NSButton* oneButton;

-(void) disableButton: (NSButton *) button{
[button setEnabled:NO];
}
-(IBAction) pressOneButton: (id) sender{

if([sender isEnabled] == YES){ // case 1
//do something;
}

if([oneButton isEnabled] == YES){ // case 2
//do something;
}
}

Obviously, I want to disable the button through the method disableButton. But unfortunately, case 1 doesn't work as my wish which case 2 does.

So, I'm puzzled. why the state of the 'sender' is different from the oneButton?



kpua
Jul 2, 2008, 02:14 AM
Are you positive that sender == oneButton? Check the pointers. You may find that things aren't connected correctly.

youngplayer
Jul 2, 2008, 02:54 AM
Oh, my God!

It's really that I forgot to bind the outlet to the component.....

Forgive this fool question..