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
0 answers

Using AFNetworking 3.0, How can I download a series of files in order?

So, I have been scouring these forums and other sites for a few days now and can not find a suitable replacement for the old way to download a series of files in AFNetworking 1.0 and 2.0. I am trying to use NSURLSessionDownloadTask to download these…
Airtower
  • 255
  • 1
  • 3
  • 10
0
votes
1 answer

Download Progress not displaying in all views ios

In my project user can download movies(nearly 1GB). If clicks on download button he is redirected to Download ViewController, there if clicks start download the download will starts and display progress bar here. Upto here there are no issues for…
0
votes
2 answers

NSOperationQueue mainQueue do not update UICollectionViewCell

While using NSURLSession to download files and display them in UICollectionView I found a problem where cells do not update correctly from NSOperationQueue block. Download part and file store works correctly every time. But update cell progress or…
0
votes
1 answer

NSURLSessionDownloadTask resume and Pause from other View ios

I have small problem with NSURLSessionDownloadTask, i.e., in my app user can download movies(nearly 1 Gb), if the user click Pause button and get back to the previous viewController then again he wants to resume the download the downloaded…
0
votes
1 answer

swift how to adopt to NSURLSessionDownloadDelegate protocol

I want to create a class that adopts to NSURLSessionDownloadDelegate protocol what i did is: class imageDelegate: NSURLSessionDownloadDelegate { } that is easy and it is fine. but i wanted to add one of it s method. i did this: class…
sarah
  • 1,201
  • 1
  • 9
  • 29
0
votes
0 answers

UILocalNotification handling issue in iOS 9

I using UILocalNotification for presenting notification when the background download completes, using the following code.` - (void)presentNotificationForDownload:(NSString *)fileName withError:(BOOL)isError { UIApplication *application =…
0
votes
1 answer

How to Continue data download in other ViewControllers

There are several files to download in a particular viewController. When a user taps on download of a particular file, a progressView appears to show the amount of data downloaded. Also at a particular time multiple files can be downloaded. Since…
0
votes
1 answer

Detecting internet connection in background in Swift

I am performing background tasks connecting to the internet to serve data to a Watch app and I would like to notify it if the paired iPhone is not able to connect to the internet. The reachability class seems not be available on Swift, and anyway I…
Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
0
votes
1 answer

How do I know if NSURLSessionDownloadTask is working when application is suspended?

When my application is running in the foreground I see periodic calls to: NSURLSessionDownloadDelegate -> URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite: When my application moves to the background and is suspended,…
drbobdugan
  • 443
  • 5
  • 12
0
votes
1 answer

NSURLSession Delegates split across classes - NSURLSession, NSURLUploadTask, NSURLDownloadTask

I'm in the process of creating an upload/download media feature for my app. I had the queue working fine for uploads but when I added downloads and the requisite download delegates the upload delegate was called event though the task was to…
0
votes
1 answer

Slow downloading of photos with NSURLSession

I am using the NSURLSession API to ask my Java servlet for some photo uploaded on my server. I then display the photo on the device in some UIImageView. The problem is it might take up to ten seconds to finally display a photo, which is about 100…
Gannicus
  • 399
  • 1
  • 3
  • 18
0
votes
4 answers

iOS get file size before downloading

I couldn't find a solution that worked for me. But I need to get the file size of a video I am downloading so that I can make sure the user has enough space on his phone for it. My thoughts are to check the size of the video, then if the user has…
0
votes
1 answer

Issue facing in changing path directory for downloaded files in swift

Facing issue, while downloading PDF through API. Issues are follows: I can download PDF through my API link. Download completed. But its path is,…
McDonal_11
  • 3,935
  • 6
  • 24
  • 55
0
votes
1 answer

Published app now won't run in XCode 7 simulator

I have an app that has been in the App Store for almost two years. Published originally for iOS 7, it was updated and runs perfectly under iOS 8, and I just downloaded XCode 7 to make sure I was ready when iOS 9 hits the streets. I am getting a…
Scooter
  • 4,068
  • 4
  • 32
  • 47
0
votes
0 answers

NSURLSession : getting null resumedata when downloading is running and in between that internet connection will change as ON to OFF mode

I am using NSURLSession for downloading zip file from server. following task working perfectly Pause and resume downloading Get Progress of downloading Get Notification of when internet is active or not active but there is major problem While…
Pravin Tate
  • 1,145
  • 8
  • 18