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];
} );

你可能感兴趣的:(StrongSelf和WeakSelf)