在 swift + alamofire 中出现错误 "Connection was lost" 时抓取下载的数据

Grab downloaded data when error "Connection was lost" occurs in swift + alamofire

我正在使用 swift 并使用 alamofire 在 Xcode 6 中开发一个 iOS 应用程序。

在应用程序中用户可以下载大尺寸 file.The 问题是如果我遇到 "connection was lost" 错误,我如何抓取下载的数据以便稍后恢复而不是从头开始?

根据https://github.com/Alamofire/Alamofire/pull/595, Alamofire 实现了以下功能:

1.For any failed download request, the resume data is automatically extracted out of the error object if it is available.

2.Added a resumeData computed property on the Request to allow you to access that data outside the response serialization methods. For example, you can now access the resumeData in any of the chained Request methods if you so choose.