검색했지만 대상 C에서만 관련 답변을 찾지 못했습니다. Swift에서 파일 다운로드 진행 상황을 확인할 수있는 방법이 있습니까? 사용자에게? 나는 iOS 프로그래밍에 익숙하지 않으며 NSURLSession을 사용해 보았지만 성공하지 못했습니다.신속한 파일 다운로드 진행 찾기
편집 : 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