如果我从一个块内调用的函数引用“自我”,是否会创建一个保留周期?块保留周期调用函数
__weak id weakSelf = self;
- (void)firstFunction
{
id strongSelf = weakSelf;
if (!strongSelf) return;
[anObject performBlock:^{
[strongSelf secondFunction];
}];
}
- (void)secondFunction
{
[self doSomeCrazyStuff];
self.counter++;
//etc.
}
我在'secondFunction'中调用'self',是否需要将弱指针传入此函数并使用它?
如果我摆脱strongSelf和使用weakSelf调用“secondFunction”,然后会在“secondFunction”的代码行创建自强引用?我问,因为'secondFunction'是从一个块内调用的。 – Thawe
@Thawe - 添加到回答 – CRD