接触OC也有段时间了,对Block的语法一直有点犯迷糊,结果发现了一个有意思的网站,FuckingBlockSyntax,下面就是这个网站的全部内容,转载一下,供以后查阅。

As a local variable:

returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};

As a property:

@property (nonatomic, copy) returnType (^blockName)(parameterTypes);

As a method parameter:

- (void)someMethodThatTakesABlock:(returnType (^)(parameterTypes))blockName;

As an argument to a method call:

[someObject someMethodThatTakesABlock:^returnType (parameters) {...}];

As a typedef: