Nsurlsession download file location
You might have heard of OperationQueue and tried to download files the downloaded file is located completionHandler(localURL, response. Posts about background download using NSURLSession written by Aswath write the data as file to documents directory NSString *fileName = [gwd.esse. public func urlSession(_ session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingTo location: NSURL) {.
importFoundation publicclassEspresso : NSObject { internalvar running:Bool=false var currDownload:Int64=-1 internalfuncdownload(urlString: String) { let config = gwd.est() let session =NSURLSession(configuration: config, delegate: self, delegateQueue: nil) gwd.esg=false let url =NSURL(string: urlString) let task = gwd.esadTask(with: url!) gwd.es() gwd.esg=true gwd.esg { sleep(1) } } } extensionEspresso : NSURLSessionDownloadDelegate { publicfuncurlSession(_session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteDatabytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) ->Void { let percentage = (Double(totalBytesWritten)/Double(totalBytesExpectedToWrite)) * ifInt64(percentage) != currDownload { print("\(Int(percentage))%") currDownload =Int64(percentage) } } publicfuncurlSession(_session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingTolocation: NSURL) { print("\nFinished download at \(gwd.esteString)!") gwd.esg=false } } let e =Espresso() gwd.esad(urlString: "gwd.es") Источник: [gwd.es]
-
-