Skip to content

Instantly share code, notes, and snippets.

@CreatureSurvive
Created November 27, 2017 03:22
Show Gist options
  • Save CreatureSurvive/7fa2a4fd00fef58b04054f5ef848544c to your computer and use it in GitHub Desktop.
Save CreatureSurvive/7fa2a4fd00fef58b04054f5ef848544c to your computer and use it in GitHub Desktop.
Objectice-C Block Syntax

Declairing blocks in Objective-C

As a local variable:

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

As a property:

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

As a method parameter:

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

As an argument to a method call:

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

As a typedef:

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

from: http://fuckingblocksyntax.com

or: http://goshdarnblocksyntax.com

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