Objective-C Block 语法
Objective-C Block 常用语法介绍。
操作方法
- 01
局部变量 returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};
- 02
作为属性(property) @property (nonatomic, copy) returnType (^blockName)(parameterTypes);
- 03
作为方法参数: - (void)someMethodThatTakesABlock:(returnType (^)(parameterTypes))blockName;
- 04
作为方法调用的参数: [someObject someMethodThatTakesABlock:^returnType (parameters) {...}];
- 05
自定义 typedef: typedef returnType (^TypeName)(parameterTypes);TypeName blockName = ^returnType(parameters) {...};
赞 (0)