私は検索しましたが、目的のCでのみ関連する回答が見つかりませんでした。Swiftでファイルのダウンロードの進捗状況を確認する方法はありますかユーザーに?私はiOSプログラミングの新人です。私はNSURLSessionを試しましたが、成功しませんでした。すぐにファイルのダウンロード進捗状況を見つける
EDIT: thisポストで見られるように、私はこの方法を使用しているが、私は進捗状況を取得する方法を理解するように見えることはできません。
func downloadFile(page: NSString){
finished = false
var statusCode:Int = 0
println("Download starting")
let url = NSURL(string: page)
let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
if error != nil {
println("download failed with error \(error?.localizedDescription)")
} else {
println("Expected Content-Length \(response.expectedContentLength)")
self.contentLength = response.expectedContentLength
if let httpResponse = response as? NSHTTPURLResponse {
println("Status Code of number \(self.countDownload) is \(httpResponse.statusCode)")
statusCode = httpResponse.statusCode
}
}
}
task.resume()
}
はあなたと仮定すると、事前に
NSURLSessionでこれをどうやって試しましたか?何が間違っていましたか? – Wain
あなたが試したことを教えてください – ColdSteel