任何人都可以帮助我如何将此代码转换为swift 3

时间:2016-10-21 12:17:09

标签: ios iphone swift3 alamofire

Alamofire更改下载请求的方法任何人都可以帮助我如何在新方法中获取response.suggestedFilename!

Alamofire.download(.GET, "url", destination:
        {
            (temporaryURL, response) in
        let pathComponent = response.suggestedFilename!
        let fileManager = NSFileManager.defaultManager()

        let directoryURL = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
        let fileUrl = directoryURL.appendingPathComponent(pathComponent)
        return fileUrl!
    })

1 个答案:

答案 0 :(得分:1)

使用新的DownloadRequest.response API时会返回DefaultDownloadResponse类型。

Alamofire.download(urlString).response { response in
    debugPrint(response)
    print(response.temporaryURL)
}

检查完整Alamofire 4.0 Migration Guide here