I noticed Apple documentation saying that we need to avoid strong reference loops when capturing ourselves.
The block in the example is a self property.
But what if I put the block as a local variable in the dispatch_async statement?
In this case, it will not create a save loop, even if I directly call the self method, right?
Is the following code generating weakSelf required in this article ?
// your code __weak typeof(self) weakSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ __strong typeof(weakSelf) strongSelf = weakSelf; if (strongSelf) { [strongSelf doThis]; [strongSelf doThat]; [Manager.sharedInstance updateSuccessCount]; } }); // more code
dispatch_async , self. , self , dispatch_async, , self . , dispatch_async.
dispatch_async
self
, , , , , , - , , , , , , self .
, self , - . .