test

作者: FancyMF | 来源:发表于2019-06-28 14:29 被阅读0次

    How Do I Declare A Block in Objective-C?

    As alocal variable:

    ```

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

    ```

    As aproperty:

    ```

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

    ```

    As amethod parameter:

    ```

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

    ```

    As anargument to a method call:

    ```

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

    ```

    As aparameter to a C function:

    void SomeFunctionThatTakesABlock(returnType (^blockName)(parameterTypes));

    As atypedef:

    typedef returnType (^TypeName)(parameterTypes);

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

    转载来自http://fuckingblocksyntax.com/

    相关文章

      网友评论

          本文标题:test

          本文链接:https://www.haomeiwen.com/subject/zxgscctx.html