【问题标题】:Can any body help me how to convert this code to swift 3任何人都可以帮助我如何将此代码转换为 swift 3
【发布时间】:2016-10-21 12:17:08
【问题描述】:

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!
    })

【问题讨论】:

  • 检查响应的“temporaryURL”或“destinationURL”属性。
  • 如果您已管理转换为 V4,请发布代码

标签: ios iphone swift3 alamofire


【解决方案1】:

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

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

检查完成Alamofire 4.0 Migration Guide here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多