block在不同地方的写法

  • 局部变量:
returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};
  • 属性:
@property (nonatomic, copy, nullability) returnType (^blockName)(parameterTypes);
  • 方法参数:
-(void)someMethodThatTakesABlock:(returnType (^nullability)(parameterTypes))blockName;
  • 方法调用参数:
[someObject someMethodThatTakesABlock:^returnType (parameters) {...}];
  • typedef:
typedef returnType (^TypeName)(parameterTypes);TypeName blockName = ^returnType(parameters) {...};

你可能感兴趣的:(block在不同地方的写法)