本文翻译自http://fuckingblocksyntax.com/
作为局部变量:
returnType(^blockName)(parameterTypes) = ^returnType(parameters) {...};复制代码
作为属性:
@property (nonatomic, copy) returnType (^blockName)(parameterTypes);复制代码
作为参数:
- (void)someMethodThatTakesABlock:(returnType (^nullability)(parameterTypes))blockName;复制代码
作为方法调用参数:
[someObject someMethodThatTakesABlock:^returnType (parameters) {...} ];复制代码
作为typedef
typedef returnType (^TypeName)(parameterTypes); TypeName blockName = ^returnType(parameters) {...};复制代码