Reputation: 9700
if (menuPlayed == TRUE && [sender tag == 0]) {
NSLog(@"You're pressing the right button at the right time");
}
Any idea why this is throwing up a "Expected "] "" error? I have absolutely no idea what's wrong with those comparisons :(
Upvotes: 0
Views: 91
Reputation: 213160
Change:
if (menuPlayed == TRUE && [sender tag == 0])
to:
if (menuPlayed == TRUE && [sender tag] == 0)
Also note that you should never write expressions such as menuPlayed == TRUE
- always write this as just menuPlayed
, i.e. in this particular case:
if (menuPlayed && [sender tag] == 0)
And as mentioned in @rokjarc's answer, you might want to add some parentheses for clarity, although these are not actually required:
if (menuPlayed && ([sender tag] == 0))
Upvotes: 3
Reputation: 18875
Change your code to:
if ((menuPlayed == TRUE) && ([sender tag] == 0))
And you'll probably have to typecast sender, something like
if ((menuPlayed == TRUE) && ([(UIButton *)sender tag] == 0))
Ofcourse you shouldn't just use (UIButton *) for typecast. Use the correct class of your sender object or use one of it's ancestor classes. I believe 'tag' is added to UIView in this object hierarchy.
Upvotes: 0