美文网首页
Block样式--OC

Block样式--OC

作者: ilmari | 来源:发表于2017-06-30 14:44 被阅读8次
    //作为一个本地变量:
    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样式--OC

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