My problem: I'm not sure if closing inside a class method can lead to a memory leak. Here is my code
class func SomeDownloadFun (pdfDirectory:String) { let destination : DownloadRequest.DownloadFileDestination = { _, response in //----------HERE I Reference the item 'pdfDirectory'-----Will this cause leak? let fileURL = URL(fileURLWithPath: pdfDirectory) return (fileURL,[.removePreviousFile,.createIntermediateDirectories]) } let downLoadRequest = Alamofire.download(urlStr!, to: destination) downLoadRequest.responseData(completionHandler: { (response) in switch response.result { case .success: //----------HERE I Reference the item 'pdfDirectory'-----Will this cause leak? print("pdfDirectory") break case .failure: print("down err") break } })
}
Aa I have a comment where I think it will leak, can someone tell me, thanks! 🙏
source share