Stats

75 Contributors: 7 Thursday, May 18, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Block

Syntax

  • As a variable:

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

  • As a property:

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

  • As a method parameter:

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

  • As a typedef:

    typedef returnType (^TypeName)(parameterTypes);

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

Related Examples