我目前有以下工作:
typedef BOOL(^InnerBlockType)(int arg1, int arg2);
- (BOOL)doStuff:(void(^)(InnerBlockType innerBlock))block;
但我想删除typedef并使块内联,因此参数在自动完成后可见,使其更易于使用 . 我可以't get the syntax right, though. I can get it 99% there, but not including giving the block a name. When I insert an identifier, Xcode tells me that it'期待 )
.
// Compiles, but is missing the inner block's name
- (BOOL)doStuff:(void(^)(BOOL(^)(int arg1, int arg2)))block;
// This is what I'd like
- (BOOL)doStuff:(void(^)(BOOL(^)(int arg1, int arg2))innerBlock)block;
// But I get a compiler error here: ^ Expected ')'
我已经尝试将 innerBlock
标识符移入和移出所有其他不同的括号组合,但我得到了相同的错误 . 我在哪里可以插入满足编译器的 innerBlock
标识符?
1 回答
删除名称:
或者像传统命名的块一样插入它:
虽然,我确实注意到自动完成给了我一个艰难的时间,它似乎并没有很好地接受它 . 结果如下: