NSButton question in cocoa

Discussion in 'Mac Programming' started by youngplayer, Jul 1, 2008.

  1. macrumors member

    Joined:
    May 16, 2008
    Location:
    Shanghai,China
    #1
    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?
     
  2. macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    Are you positive that sender == oneButton? Check the pointers. You may find that things aren't connected correctly.
     
  3. thread starter macrumors member

    Joined:
    May 16, 2008
    Location:
    Shanghai,China
    #3
    Oh, my God!

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

    Forgive this fool question..
     

Share This Page