So I have a method I call when one of three buttons is pressed:
- (IBAction)saveNetwork:(id)sender
{
NSString *networkEntered;
if (sender == button1)
networkEntered = @"button1";
if (sender == button2)
networkEntered = @"button2";
if (sender == button3)
networkEntered == @"button3";
//more work...
}
the problem is, that it never hits the third if, no matter what is passed in as sender. I’ve tried else if’s, else, etc…
any ideas what’s going on?
the problem isn’t how I’m passing in the button objects or anything like that because if it is button1 that is pressed, it enters the if just fine, but for some reason it never checks the last one at all.
thanks in advance for the read and the help.
You have a comparison == in your third if block. Instead of
networkEntered == @"button3";you likely want to havenetworkEntered = @"button3";I expect your third if block is being entered, just not doing what you expect it to.