Block Syntax
Block as a local variable returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...}; |
|
Block as a property @property (nonatomic, copy) returnType (^blockName)(parameterTypes); |
|
Block as a method parameter - (void)someMethodThatTakesABlock:(returnType (^)(parameterTypes))blockName; |
|
Block as an argument to a method call [someObject someMethodThatTakesABlock: ^returnType (parameters) {...}]; |
|
Block as typedef typedef returnType (^TypeName)(parameterTypes); TypeName blockName = ^returnType(parameters) {...}; |
Notes
- Based on a cheat sheet by Mike Walker