I have the following Swift code:
func callback(_ status: PHAuthorizationStatus) {
}
func myFunction() {
let handler:(PHAuthorizationStatus) -> Void = { (status) in
self.callback(status)
}
PHPhotoLibrary.requestAuthorization(for: .addOnly) { (status) in
handler(status)
}
}
What my doubt is whether there is a retain cycle in closures declared as local variable and whether we should use unowned or weak self instead inside handler. How does Swift handle closures declared as local var inside function?