I have read a tutorial about GCD in swift from https://www.raywenderlich.com/5370-grand-central-dispatch-tutorial-for-swift-4-part-1-2 In the first part the writer wrote :
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
guard let self = self else {
return
}
let overlayImage = self.faceOverlayImageFrom(self.image)
// 2
DispatchQueue.main.async { [weak self] in
// 3
self?.fadeInNewImage(overlayImage)
}
}
Based on what i know after read swift document from Apple, I think using "unowned" keyword is better because self is a viewcontroller and it has a longer life than closure property. And we also do not need unwrap the optional self. Can you explain more details about this case ? Thanks!