在不使用 typedef 的情况下声明块方法参数 [英] Declare a block method parameter without using a typedef
本文介绍了在不使用 typedef 的情况下声明块方法参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在不使用 typedef 的情况下在 Objective-C 中指定方法块参数?它必须像函数指针一样,但如果不使用中间类型定义,我就无法找到获胜的语法:
Is it possible to specify a method block parameter in Objective-C without using a typedef? It must be, like function pointers, but I can't hit on the winning syntax without using an intermediate typedef:
typedef BOOL (^PredicateBlock_t)(int);
- (void) myMethodTakingPredicate:(PredicateBlock_t)predicate
只有上面的编译,所有这些都失败了:
only the above compiles, all these fail:
- (void) myMethodTakingPredicate:( BOOL(^block)(int) ) predicate
- (void) myMethodTakingPredicate:BOOL (^predicate)(int)
而且我不记得我尝试过哪些其他组合.
and I can't remember what other combinations I've tried.
推荐答案
- ( void )myMethodTakingPredicate: ( BOOL ( ^ )( int ) )predicate
这篇关于在不使用 typedef 的情况下声明块方法参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文