In Alamofire 4, the .response method takes a single parameter closure, DefaultDownloadResponse .
By the way, if you are going to use your own download path, I am confused by your return finalPath! , because Alamofire 4 expects you to return a tuple consisting of the file URL and options, of which .removePreviousFile is one of the options, which saves you from manually deleting it yourself.
For instance:
Alamofire.download(urlToCall, method: .get) { temporaryURL, response in let finalURL: URL = ... return (destinationURL: finalURL, options: .removePreviousFile) }.response { response in if let error = response.error { success(nil) return } if let fileURL = response.destinationURL, let dictionary = NSDictionary(contentsOf: fileURL) { success(dictionary) } else { success(nil) } }
Rob source share