views:

61

answers:

1

Hello

I am really getting frustrated now! I have a new problem now, all I want to do is say if

lblMessage.Text = "30 Seconds" then do some code otherwise do some other code

if (lblMessage.text isEqualToString:@"30 Seconds")
{
    NSString *strPlayerAtTable = [[NSString alloc] initWithFormat:@"%@ at table", ActivePlayer];
    lblMessage.text = strPlayerAtTable;
}
else
if (nStopClockPos == 30)
{
    lblTime.textColor = [UIColor yellowColor];
    lblMessage.text = @"30 Seconds";
}

I get the error Expected ) before isEqualToString

Have I got to put it into a new string variable or something?

Cheers

Paul

+7  A: 

Try adding brackets in the if statement to actually call the NSString comparison method:

if ([lblMessage.text isEqualToString:@"30 Seconds"])
Dimitris
Explanation: `isEqualToString:` is not an operator; you need to send an `isEqualToString:` *message*, and in order to do that, you need a message expression, which is always enclosed in square brackets. This even applies within the round brackets (a.k.a. parenthetical marks) of the `if` statement's condition.
Peter Hosey
Other explanation: `lblMessage.text` is an `NSString` object and as a member of this class it has a method called `isEqualToString:(NSString *)`. So you need to call that method (this is done using square brackets) and pass as an argument the NSString you want to compare it against (in this case `@"30 Seconds"`).
Dimitris
thanks for this
Rupert