我有一个变量,它是带有Bool返回值和void参数的块类型。
@property (nonatomic, copy) BOOL (^shouldDisplayView)(void);
我在另一个我的类中实现了这个块
myClass.shouldDisplayView = ^BOOL(void) {
return self->_count > 0;
};
我要执行此块并检查结果,例如:
if (result of shouldDisplayView is true) ...
简单吗
if (shouldDisplayView)
还是检查它是否为非空?
if (myClass.shouldDisplayView)
将检查shouldDisplayView
不是nil
。
如果要检查shouldDisplayView
is的结果true
,则应为
if (myClass.shouldDisplayView && myClass.shouldDisplayView())
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句