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
1 answer

iOS NSURLSession Listen to Timeout

I created a simple NSURLSessionDownloadTask to download from a URL, with its class having the NSURLSession delegates: @interface DownloadManager : NSObject
0
votes
1 answer

How to download multiple files by NSURLSessionDownloadTask

iOS 8, XCode 6.3.2 I want to download multiple files serially. In the wake of the Push notification, APP will start BackgroudDownload by NSURLSessionDownloadTask. After the First BackgroudDownload process has been completed, APP want to start Second…
0
votes
0 answers

NSURLSession: how to start downloading again, but not resume to download?

I use NSURLSession, and NSURLSessionDownloadTask to download o file. During the downloading time, I kill the application (by tapping on home button, and swipe off the application). I received an error "Cancel" in the following function as I…
chipbk10
  • 5,783
  • 12
  • 49
  • 85
0
votes
1 answer

How to pass cookie to NSUrlSession?

For iOS, I have written a custom delegate and implementation of NSUrlSession. It is working fine for Http urls. But when I try to download image resources from a HTTPS source that has been authenticated and which require a Cookie to be passed, the…
B K
  • 1,554
  • 3
  • 19
  • 40
0
votes
1 answer

What is the delegate method called when the URLSessionDownloadTask start?

There are three methods in NSURLSessionDownloadDelegate…
firelyu
  • 2,102
  • 5
  • 25
  • 29
0
votes
0 answers

NSURLSessionDownloadDelegate generates errors with UIImage

I've recently been working on a simple iOS application that uses a NSURLSessionDownloadTask to download an image from a web server. The download task executes perfectly, but dealing with the received image has proved to be a little odd. It seems as…
Jeffrey
  • 1,271
  • 2
  • 15
  • 31
0
votes
0 answers

iPhone iOS 7 - Background Download NSUrlSession

Welcome, Now i'm implementing NSURLSession Download Process but i have an issue. Suppose i have a list and user clicked to download the 1st element in the list then decided to go back to previous view ,after that re-opened the download view again ,…
0
votes
0 answers

How to cancel NSURLSessionDownloadTask with AFURLSessionManager?

I wanna download some pictures with AFURLSessionManager in method @selector(collectionAction): NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AFURLSessionManager *manager = [[AFURLSessionManager…
magic_9527
  • 243
  • 3
  • 18
0
votes
1 answer

iOS - Background Transfer Service for Auto Update data at fixed intervel

I am developing an app of feeds, that fetches feed from server and display to users for read. It working fine when app starts but i want to load data in background when is suspended or terminate(in both case). As we can create IntentService in…
0
votes
1 answer

Downloading a pdf file using NSURLSessionDownloadTask from redirect URL

I'm making an app where the user login to a website and download some pdf files. i was able to login successfully into the site using URLSession. Now my problem is with the download of the file. The website uses a url with the following…
kupilot
  • 494
  • 1
  • 3
  • 15
0
votes
1 answer

URLSession Download Task delegate only called after all tasks finish

I have an NSURLSession with a background configuration downloading two or three files simultaneously. Everything seems to be working fine except that the delegate methods -(void)URLSession:(NSURLSession *)session…
RL2000
  • 913
  • 10
  • 20
0
votes
0 answers

How much time is allowed and what kind of task is allowed in NSURLSessionDelegate in background mode

Do you how much time is allowed when the OS calls methods of NSURLSessionDelegate and NSURLSessionDownloadDelegate when the app crashed or is suspended using a background NSURLSession. Do you know if I can perform the following actions inside …
0
votes
0 answers

How to retrieve results outside of NSURLSessionDownloadTask thread?

How do I retrieve the results from my NSURL file? In this example, in the completionHandler, my results are place in a file called *localfile. I am then parsing the local file with NSXMLParserDelegate in a separate NSObject. Everything works…
Paul S.
  • 1,342
  • 4
  • 22
  • 43
0
votes
1 answer

Parallel NSURLSession connection with iOS 7 Background Fetch

I wonder whether it is possible to have multiple downloads when background fetch is happening (iOS7 Background Fetch). Currently I have an app which download data from around 6 RESTful api. These API calls use NSURLSession and download data…
Chinthaka
  • 966
  • 1
  • 13
  • 42
0
votes
1 answer

Downloading images when the app is in idle state usingNSURLSession iOS

I have a requirement to download some of the large images to the app while the app is in idle state.I am planing to make it done using NSURLSession.Tutorials and the sample code available worked and confirmed the background download is possible.Is…
iOS Developer
  • 1,723
  • 2
  • 16
  • 47
1 2 3
20
21