Skip to content

Instantly share code, notes, and snippets.

@wangzz
Last active August 29, 2015 14:01
Show Gist options
  • Save wangzz/de7c9d52bb4d7b29107b to your computer and use it in GitHub Desktop.
Save wangzz/de7c9d52bb4d7b29107b to your computer and use it in GitHub Desktop.
记录有用的代码片段
记录有用的代码片段
it is a test file.
@wangzz
Copy link
Author

wangzz commented Nov 25, 2014

Block 使用方式

How Do I Declare A Block in Objective-C?

  • 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:
typedef returnType (^TypeName)(parameterTypes);
TypeName blockName = ^returnType(parameters) {...};

URL:
http://goshdarnblocksyntax.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment