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

Not sure why NSURLSession times out

I'm not sure why my app crashes due to a "request timed out" error. It absolutely doesn't make sense to me because I'm getting a response back with the data i'm expecting. Some context: Every time the user scrolls the mapview, I make a call to the…
Mihado
  • 1,487
  • 3
  • 17
  • 30
1
vote
2 answers

iOS: Programmable Network Link Conditioner for Testing

Is there a way to programmably create an effect like the iOS Network Link Conditioner for your own code, while the code is running? The specific condition I want to test is "Step 1 of a login flow works, but network cuts out for Step 2". This is…
bcattle
  • 12,115
  • 6
  • 62
  • 82
1
vote
0 answers

Unexpected behaviour of URLSession while trying to get bytes uploaded

My application is continuously communicating with server and I want to calculate the bandwidth I am getting. For that I decided to calculate upload and download speed. I am using NSURLSession to communicate with my server. What I am doing is:…
1
vote
4 answers

Reload table after request was finished

I have a table view that use result of fetching data with NSURLSession as a datasource. Here is my NSArray which is responsible about that table. @property (strong, nonatomic) NSMutableArray *results; And this is my delegate and datasource…
Sonic Master
  • 1,238
  • 2
  • 22
  • 36
1
vote
1 answer

Get JSON from NSURLSession with IOS

I'm building my app with TheMovieDB API but my JSONObject always is nil.I don't know what I'm doing wrong.This is my code: @implementation SKTMovieLibrary -(id) init{ if (self = [super init]) { NSURL *url = [NSURL…
Skurt
  • 11
  • 7
1
vote
1 answer

NSURLSession and NSURLProtocol issue on iOS 8

I have an app working just fine on iOS 9 with a Custom NSURLProtocol implemented with NSURLSession. All the requests executed by the client are done with NSURLSession as well and each sessionConfiguration is registering to the protocol before…
iOSAddicted
  • 389
  • 1
  • 17
1
vote
1 answer

Return data from Rest API call from Swift NSURLsession

How do I get the data that is returned from a rest API call to Raspberry Pi's sensor? I have been using postman to manipulate the GET and POST calls so I can see that it works and see the response. The information returned in the xcode console is as…
GSiklos
  • 21
  • 2
1
vote
1 answer

Get NSData after completion of NSURLSession

I am fetching data using NSURLSession but I don't know how to get the data back once the download is complete my code : class ViewController: UIViewController,NSURLSessionDelegate,NSURLSessionDataDelegate{ @IBOutlet var imageView:…
remy boys
  • 2,928
  • 5
  • 36
  • 65
1
vote
1 answer

Deadlock inside NSURLSession delegate queue

I'm experiencing a deadlock inside one of the operations in the NSUrlSession delegate queue when using Alamofire. it happens when i'm doing at least one download and one upload simultaneously (all requests are done through the default Alamofire…
yeps
  • 31
  • 1
  • 6
1
vote
2 answers

I want to change my code of post data to url from NSURLConnection to NSURLSession

It seems that every time I want to edit and update my app, Apple has changed something that blocks me from 'let me just edit that quickly and upload my new version'. They now have disabled the possibility to use NSURLConnection for the Watch. I have…
1
vote
0 answers

Is it possible to use AFNetworking in a TodayExtension?

I'm using AFNetworking inside my iOS App without any problem. But now, I need to perform some API calls to my backend from my TodayExtension. When I have tried to add any kind of AFNetworking class to my TodayExtension target, the compiler…
EnriMR
  • 3,924
  • 5
  • 39
  • 59
1
vote
1 answer

webService request on https url with self signed certificate doesn't work?

I am trying to call a web service using NSURLSession and NSURLSessionDataTask, the site is an HTTPS and using a self-signed certificate, I tried to set the delegate for NSURLSession and call its method to let the request proceed, but it doesn't work…
AShi
  • 33
  • 4
1
vote
0 answers

NSURLSession background upload using the chunk transfer

I am using the NSURLSession to perform the upload of a file using the chunk transfer. self.dataTask = [self uploadTaskWithRequest:urlRequest fromData:urlRequest.HTTPBody progress:nil completionHandler:^(NSURLResponse *response, id responseObject,…
Raghav
  • 625
  • 1
  • 12
  • 31
1
vote
0 answers

Handling HTTPS certificates with NSURLSession

I want to learn how to deal with SSL certificates and HTTPS requests in iOS, and I've read this tutorial to try to get the basics but, since it uses NSURLConnection and it became deprecated in iOS 9, I've been looking for an example/tutorial of this…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
1
vote
1 answer

Issues accessing key value in JSON response from NSURLSession (Lyft API)

I'm working with the new Lyft API, in the Authentication section it says to send a request for an access token and shows an example response, with a key called "access_token". Sample response HTTP/1.1 200 OK Content-Type:…
Echizzle
  • 3,359
  • 5
  • 17
  • 28