block作为参数的使用

2018-06-01  本文已影响10人  流年易逝_李

持有block

@property (nonatomic, copy) void(^locationBlock)(CLLocation *location);

传参block

- (void)updateLocation:(void(^)(CLLocation *))locationBlock;

调用block

if (self.locationBlock) {

        self.locationBlock(locations.firstObject);

        self.locationBlock = nil;

    }

可用typedef 简化

上一篇下一篇

猜你喜欢

热点阅读