【发布时间】:2016-03-28 20:48:33
【问题描述】:
当只有外部闭包是来自self 的引用时,我是否需要在内部闭包中使用weak self?外闭包是否捕获self,即使它仅用于内闭包?
self.myClosure = {
// First do something in the background without self...
// Then do something in the main thread with self...
dispatch_async(dispatch_get_main_queue()) {
[weak self] in // IS THIS REALLY NEEDED?
self?.underlyingImage = img
self?.imageLoadingComplete()
}
}
【问题讨论】:
-
是的,您需要
weak self。我想你可能真的需要它在外部封闭。