Questions tagged [nsurlsession]

NSURLSession is the API for HTTP connections introduced in iOS 7 and OS X 10.9.

The class NSURLSession was introduced to Apple's Foundation.framework in iOS 7 and OS X 10.9.

A NSURLSession object can be considered a group of related data transfer tasks. A response may be received and can be handled via a block statement or delegate methods. NSURLSession provides status and progress properties, of which support canceling, resuming, or suspending tasks, and resuming suspended, canceled, or failed downloads.


Types of Sessions

NSURLSession can support three different types of sessions, which is determined by the configuration object used to initialize the session object.

  • Default Sessions
  • Ephemeral Sessions
  • Background Sessions

Types of Tasks

There are three types of tasks, the last two (Download & Upload) of which support background use.

  • Data Tasks - Send and receive data via a NSData object
  • Download Tasks - Retrieves data in the form of a file
  • Upload Tasks - Sends data, most typically in the form of a file

Related tags to explore:

Adapted from Apple's URL Loading System Programming Guide > NSURLSession.

2479 questions
1
vote
4 answers

iOS NSURLSessionUploadTask response data

I have successfully implemented the NSURLSessionUploadTask and work in both background and foreground. But there is an issue when reading the response data. - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask…
1
vote
0 answers

IOS Float Not Being Sent Through POST Request

I am have been trying to send a post request from one of my ViewControllers which collects some data from another ViewController through - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender Anyways when I try to send the post…
user1502224
  • 95
  • 2
  • 13
1
vote
1 answer

NSURLSessionUploadTask does not respond to resume ios8 Beta3 (Device only)

When sending the resume method on a NSURLSessionUploadTask using a background client, NSURLSessionConfiguration:backgroundSessionConfiguration:, the process never begins. I can not reproduce on simulator, only on the device, and only on 8.0. This is…
Ryan Romanchuk
  • 10,819
  • 6
  • 37
  • 41
1
vote
1 answer

How can I get NSURLSession to process completionHandler when running as a command-line tool

I am somewhat new to Objective-C. I have some PERL scripts that download files from a site that requires client certificate authentication. I would like to port those scripts from PERL to Objective-C command line tools that I can then run from…
1
vote
0 answers

NSURLSession multiple background uploads

In my app I am creating a background session with a single identifier, (using the singleton method) that has ~50-100 upload tasks(images) when the user tries to upload their "Orders". Each Order has ~25 images to upload. I am storing the OrderID as…
1
vote
1 answer

Silence unimplemented protocol method warning for NSURLSessionDownloadTask

I'm trying to figure out how to suppress a compiler warning for a delegate method that I have no purpose of using. I know I could have an empty method body, but I would still like to find a way to not do this, so it is less code in my source. I saw…
klcjr89
  • 5,862
  • 10
  • 58
  • 91
1
vote
0 answers

How to pass an HTTP as a header in with NSURLSession

I'm trying to submit a GET request from a web service and I want to pass a JSON argument as a parameter in the HTTP header. I have the following code that performs the get request without the JSON argument. How would I add the JSON argument in the…
user2604504
  • 697
  • 2
  • 14
  • 29
1
vote
1 answer

Inheritance, AFNetworking, Good Practices?

I am working on an app that will connect to different data providers, as I started developing different classes to handle those providers I started seeing similarities between the functionality I needed. so I decided to create a base classs that…
Eddie
  • 949
  • 1
  • 8
  • 15
1
vote
0 answers

Access Request Data NSUrlProtocol with SessionClient

I'm having trouble intercepting SessionClient post requests using AFMotion SessionClient. Weirdly, my code works fine when using a generic AFMotion::HTTP.post action class Protocol < NSURLProtocol def self.canInitWithRequest(request) return…
JonMorehouse
  • 1,313
  • 6
  • 14
  • 34
1
vote
1 answer

NSURLSession performSegueWithIdentifier not running

I have the following code but unsure why its not running: NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: [NSURL URLWithString:myURLString] completionHandler:^ (NSData…
tau
  • 288
  • 4
  • 19
1
vote
1 answer

NSURLSession and NSURLConnection Compatibility

NSURLSession is a refactoring of NSURLConnection and introduces some new features. I've been working on an issue with an app that uses both, and I'm wondering if this is OK. Or is it necessary to abandon NSURLConnection methods completely when…
Victor Engel
  • 2,037
  • 2
  • 25
  • 46
1
vote
1 answer

Can we set a custom delegate object for NSURLSessionTaskDelegate

In NSURLSession, we add tasks to a session by methods like dataTaskWithRequest: dataTaskWithRequest:completionHandler: As far as I understand, if we use the one without completionHandler or use nil for completionHandler, self will be used…
jqyao
  • 170
  • 6
1
vote
1 answer

NSURLSessionDownloadTask cancelByProducingResumeData return null

I use NSURLSessionDownloadTask to download a file from server, it is run in a background session. I want to save resume data to resume the download when the app is terminated. However, the call of cancelByProducingResumeData always returns null. I…
1
vote
2 answers

How do you update UITableViewController after download completes

I have a tableViewController, that when it loads a cell it calls another class, DownloadData which is a UIOBject, which initializes a bunch of data. That class calls a downloader which downloads a file. I don't want to wait for this file to be…
Diesel
  • 5,099
  • 7
  • 43
  • 81
1
vote
0 answers

Crash UIProgressView + NSURLSessionDownloadTask

I get crash when begin download file in DownloadsViewController and then close this controller. Example with bug - https://github.com/nullproduction/AFNetworingBug Screen with crash - http://rghost.ru/55518252/image.png Code: -…
nullproduction
  • 576
  • 3
  • 18