Objective-C:if(object)Vs. if(object!= nil) [英] Objective-C: if (object) Vs. if (object != nil)
本文介绍了Objective-C:if(object)Vs. if(object!= nil)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设 object
是一种 NSObject
,以下if语句是等效的, ?
Assuming object
is a kind of NSObject
, the following if statements are equivalent, but which style should I use?
if (object) {
// ...
}
或
if (object != nil) {
// ...
}
推荐答案
如你所说,它们是等价的。因此...
As you say, they're equivalent. Thus...
$ b
which style should I use?
无论您想要什么。
这篇关于Objective-C:if(object)Vs. if(object!= nil)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文