0
我有60远程文件(影像)的列表,我想下载所有的人,但是当我尝试只是在这里下载15幅我的代码不完整的文件下载与alamofire
let destination = Alamofire.Request.suggestedDownloadDestination(directory: .DocumentDirectory, domain: .UserDomainMask)
for var i = 1; i < 61; i++ {
Alamofire.download(.GET, "https://domain.com/folder/\(i).jpg", destination: destination)
.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
dispatch_async(dispatch_get_main_queue()) {
print("Total bytes read on main queue: \(totalBytesRead)")
}
}
.response { _, _, _, error in
if let error = error {
print("Failed with error: \(error)")
} else {
print("Downloaded file successfully")
}
}
}
任何想法???
说不上什么alamofire是,但它看起来像你正在下载太多太快,我会下载一个在同一时间,我就会把它的答案,这样的代码是更好 – Knight0fDragon