[英]Objective-C IF statement with OR condition
What's wrong in this IF statement? 这个IF声明有什么问题?
if ([currentElement isEqualToString:@"aaa" || currentElement isEqualToString:@"bbb"])
XCode says: XCode说:
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. 如果它可以帮助我进入NSXML Parser程序,但我认为这不是问题所在。
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 那就是编译器试图调用不存在的isEqualToString:isEqualToString:
NSString的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.