具有OR条件的Objective-C IF语句 [英] Objective-C IF statement with OR condition

查看:341
本文介绍了具有OR条件的Objective-C IF语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个IF语句出了什么问题?

What's wrong in this IF statement?

if ([currentElement isEqualToString:@"aaa" || currentElement isEqualToString:@"bbb"])

XCode说:

No visible @interface for 'NSString' declares the selector 'isEqualToString:isEqualToString:'

如果它可以帮助我进入NSXML Parser程序,但我认为这不是问题所在。

I'm into an NSXML Parser procedure if it can help, but I think it's not that the problem.

推荐答案

您必须比较两个方法调用的结果:

You must compare result of two method calls:

if ([currentElement isEqualToString:@"aaa"] || [currentElement isEqualToString:@"bbb"])

您实际编译的代码为

if ([currentElement isEqualToString:(@"aaa"||currentElement) isEqualToString:@"bbb"])

编译器尝试调用不存在的 isEqualToString:isEqualToString:方法的NSString

that is compiler tries to call non-existing isEqualToString:isEqualToString: method of NSString

这篇关于具有OR条件的Objective-C IF语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆