Questions tagged [nsurlsessiondownloadtask]

An NSURLSessionDataTask is a concrete subclass of NSURLSessionTask. The methods in the NSURLSessionDataTask class are documented in NSURLSessionTask Class Reference.

An NSURLSessionDataTask behaves differently from other subclasses in several subtle ways:

  • An NSURLSessionDataTask object returns data directly to the app rather than through a file (as a download task would).
  • During upload of the body data (if your app provides any), the session periodically calls the delegate’s URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend: method with status information. (It also calls this method for upload tasks.) Upon receiving an initial response, the session calls the delegate’s URLSession:dataTask:didReceiveResponse:completionHandler: method to provide your app with the opportunity to convert the transfer into a download task depending on the returned MIME type and other information.

  • If your app converts the transfer into a download task, the session calls the delegate’s URLSession:dataTask:didBecomeDownloadTask: method to provide your app with the new download task.

  • During the transfer, the session calls its delegate’s URLSession:dataTask:didReceiveData: method with data objects containing bits of data as it is received. Upon completion, the session calls its delegate’s URLSession:dataTask:willCacheResponse:completionHandler: method to determine whether the response should be cached.

  • If this delegate method is provided, it must call the provided completion routine; otherwise, your app leaks memory.

  • If this delegate method is not provided, the default behavior is to use the caching policy specified in the session’s configuration object.

  • Unlike download tasks, requests made through NSURLSessionDataTask objects cannot be resumed after they are canceled.

309 questions
0
votes
2 answers

Having issue with multiple file downloads

Currently I'm implementing a file download application. In my application server there are around 2500 Resource files, I need to download those files from server to my document directory. My Code: @implementation DownloadManager { NSURLSession…
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
0
votes
2 answers

Error in NSURLSessionDownloadTask

I am trying to update the user's location on the backoffice even while the app is in backgound, so I trigger a location update calling the following php script: -(void)locateUserAtLocation:(CLLocation*)location{ NSDictionary* dict=[self…
Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
0
votes
1 answer

Intermittent server error in iOS7

I am using NSURLSessionDownloadTask to pull down a simple text file from my goDaddy server using the following code: -(void)getTheInternetFile //Fire up the downloadTask to pull the file down from my web server. NSURLSessionDownloadTask *getTheFile…
Scooter
  • 4,068
  • 4
  • 32
  • 47
0
votes
1 answer

If I want to get the progress of an image download using NSURLSession, do I have to use the download methods over data?

NSURLSession has NSURLSessionDataTask and NSURLSessionDownloadTask and I'm more of a fan of data, as I don't need to retrieve it from the file system. The NSURLSessionDownloadTaskDelegate has a method for retrieving progress on the download, though…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
-1
votes
1 answer

How to delegate URLSessionDownloadDelegate

I have implemented this code that download a files from remote I want to create progress bar but Delegate not works. Can you help me to understand the problem for this issue? Thanks a lot to all import UIKit class ViewController: UIViewController,…
TheCesco1988
  • 280
  • 1
  • 2
  • 10
-1
votes
1 answer

download using Alamofire failed with app termination

i want to write a downloader app i wrote pretty much of it but i have a serious problem my request simply cancels when the user terminates the app and when i run the app again i must download it from the beginning and i don't know how to store…
-1
votes
1 answer

Using downloadtask with url

I'm trying to use downloadTaskWithURL() but upgrading it to the latest version: downloadTask and I'm trying to run this code snippet but it won't compile. Here's what I have done so far: let downloadTask: URLSessionDownloadTask =…
Euridice01
  • 2,510
  • 11
  • 44
  • 76
-1
votes
1 answer

Download all available (and new) files

I'm using NSURLSessionDownloadTask to download some .mov files from a web and storing them in my app. Now what I'd like to achieve is to download ALL files of certain type (in this case .mov) available on the page, without having to specify every…
fabdurso
  • 2,366
  • 5
  • 29
  • 55
-2
votes
2 answers

Download Multiple Images Sequentially using NSURLSession downloadTask in Objective C

My app offers the option to download 3430 high resolution images from our server, each image of size 50k - 600k bytes. The original approach was to just download all of them - but we realized that gave a lot of NSURLErrorTimedOut errors and crashed…
maddie
  • 1,854
  • 4
  • 30
  • 66
1 2 3
20
21