StrongSelf和WeakSelf

我们在研发的过程中,为了避免循环引用常常会用weak若饮用来打破循环链

    __weak typeof(self) weakSelf = self;

但是有时候,在异步多任务的时候,为了避免weakself提前被释放,需要配合

    __strong typeof(self) strongSelf = weakSelf;

讲的比较清晰的文章

__weak __typeof__(self) weakSelf = self;
dispatch_group_async(_operationsGroup, _operationsQueue, ^
{
    __typeof__(self) strongSelf = weakSelf;
    [strongSelf doSomething];
    [strongSelf doSomethingElse];
} );
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容