【发布时间】:2012-06-14 17:07:53
【问题描述】:
我有一个对象,如果成功则返回一个值,如果失败则返回 false(或 nil)。
我想将该值赋给一个变量
if(var1 = [object foo])
{
//if the [object foo] returned a variable, goes here
}
else
{
//[object foo] returned FALSE (or nil), go here
}
如果赋值有效,是否可以检测 If 语句?
【问题讨论】:
-
有效是什么意思?您提供的代码将起作用,但通常最好将作业包装在
()中,所以if((var1 = [object foo])) -
任何不为 false 或 nil 的东西
标签: objective-c ios if-statement