如果我從一個塊內調用的函數引用「自我」,是否會創建一個保留週期?塊保留週期調用函數
__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