在不使用typedef的情况下声明块方法参数 [英] Declare a block method parameter without using a typedef

查看:90
本文介绍了在不使用typedef的情况下声明块方法参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Objective-C中指定方法块参数而不使用typedef?它必须像函数指针一样,但是如果不使用中间的typedef,我就无法使用获胜的语法:

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屋!

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