我试图弄清楚如何声明一个将块作为参数并仅从外部范围记录整数值的方法。我看到的大多数示例都是在某些 Apple API 上执行此操作,indexesOfObjectsPassingTest:
但我只想创建自己的简单版本。这就是我所拥有的,目前无法正常工作:
@interface IAViewController ()
+(void)tell2:(void(^)(void)) thisBlock;
@end
...
NSInteger someInt=289456;
[IAViewController tell2:^{
NSLog(@"what is this? %i", someInt);
}];
// ? how do I make this method signature work
+(void) tell2:(void (^thisBlock)) myInt{
thisBlock(myInt);
}
如何使方法签名参数正常工作以输出 289456?