最近使用的block一点注意事项

(void(^)(POPAnimation *anim, BOOL finished)) block
blcok写在了属性中.
@property (nonatomic,strong) void(^monitoringBlock)(CMTime time);
【最近使用的block一点注意事项】在多线程环境下(block中的weakSelf有可能被析构的情况下),需要先将self转为strong指针,避免在运行到某个关键步骤时self对象被析构。

最近使用的block一点注意事项
文章图片
Paste_Image.png

__weak __typeof(self)weakSelf = self; AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { __strong __typeof(weakSelf)strongSelf = weakSelf; strongSelf.networkReachabilityStatus = status; if (strongSelf.networkReachabilityStatusBlock) { strongSelf.networkReachabilityStatusBlock(status); } };

    推荐阅读