What's wrong in this IF statement?
if ([currentElement isEqualToString:@"aaa" || currentElement isEqualToString:@"bbb"])
XCode says:
No visible @interface for 'NSString' declares the selector 'isEqualToString:isEqualToString:'
I'm into an NSXML Parser procedure if it can help, but I think it's not that the problem.
For example, the following valid code: int x = 10; if (x > 10) x = 10; Essentially if the boolean expression evaluates to 1 (true) then the code in the body of the statement is executed (see Objective-C Operators and Expressions for more details of this type of logic).
The if/else statement With the if statement, a program will execute the true code block or do nothing. With the if/else statement, the program will execute either the true code block or the false code block so something is always executed with an if/else statement.
The syntax of an if statement in Objective-C programming language is − if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ } If the boolean expression evaluates to true, then the block of code inside the if statement will be executed.
The syntax for if statement is as follows: if (condition) instruction; The condition evaluates to either true or false. True is always a non-zero value, and false is a value that contains zero.
You must compare result of two method calls:
if ([currentElement isEqualToString:@"aaa"] || [currentElement isEqualToString:@"bbb"])
The code you have actually compiles as
if ([currentElement isEqualToString:(@"aaa"||currentElement) isEqualToString:@"bbb"])
that is compiler tries to call non-existing isEqualToString:isEqualToString:
method of NSString
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With