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

NSURLSession iOS CodeIgniter don't send POST

This is the way I launch the http request : let config = NSURLSessionConfiguration.defaultSessionConfiguration() config.HTTPAdditionalHeaders = ["Accept": "application/json", "Content-Type": "application/json", …
Aymenworks
  • 423
  • 7
  • 21
1
vote
1 answer

Manage completion handler of NSURLSession from a custom class

Part of my app deals with creating a Login check for the user based on a unique code provided to them. To make my application properly structured, I've created a network Helper class to deal with all network operations. Here's How i call my helper…
firecast
  • 988
  • 2
  • 10
  • 20
1
vote
1 answer

Unable to sustain a Constant Speed while Uploading files in the background with NSURLSession

I am trying to upload some 100 images to S3 in the background with AFURLSessionManager in small batches of 10 like what is being done here- Manage the number of active tasks in a background NSURLSession I am using a shared NSURLSession and adding…
Xcoder
  • 1,762
  • 13
  • 17
1
vote
0 answers

NSURLSessionDownloadTask does not complete on device

I'm trying to implement a NSURLSessionDownloadTask with the following code in swift and iOS 8: var dlURL = NSURL(string: http://thedownloadurl") var defaultConfigObject =…
Ron
  • 1,047
  • 13
  • 18
1
vote
1 answer

NSURLSession Authorization with post request

When i am trying to make a post request without (www-authorization) with NSURLSession and dataTaskWithRequest (i am using custom delegate). It works well. (i send the request, on the server i just print echo $_POST['name'] and i get the "name" as…
BOTU
  • 75
  • 1
  • 10
1
vote
1 answer

-1001 error when NSURLSession via httpproxy and /etc/hosts

I am trying to setup a http proxy server in my computer to simulate a virtual development environment. To access the local url, I put the DNS info into computers' /etc/hosts. Here is my test code: NSURLSession *session = [NSURLSession…
chao787
  • 1,760
  • 3
  • 18
  • 20
1
vote
1 answer

NSURLSession resume upload video

I am uploading a video using NSURLSession, right now my video is successfully uploaded. but once wifi connection OFF, the below delegate method is executed right away. - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task…
QueueOverFlow
  • 1,336
  • 5
  • 27
  • 48
1
vote
1 answer

NSURLSESSION background download multiple

I have this requirement , I need to download a playlist of files in the background . each file is a different url in the playlist . The issue i can start download for second file only after the first one is completed . Do any one have faced this…
1
vote
0 answers

Amazon S3 Upload using NSURLSession in the background

I've been doing a application which involves uploading videos to S3(comparatively large size) using AWS iOS SDK enabling background mode/fetch. However I have observed that the background upload task continues for a while approx 3 mins and then it…
Xcoder
  • 51
  • 1
1
vote
1 answer

dataTaskWithURL doco, what does: error value of { NSURLErrorDomain, NSURLErrorCancelled } mean?

Say you're using NSURLSession dataTaskWithURL: ... self.currentConnection = [sess dataTaskWithURL:goUrl completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { [self.results addObjectsFromArray: [self…
Fattie
  • 27,874
  • 70
  • 431
  • 719
1
vote
2 answers

App doesn't work when downloaded from app store, but works in xcode

I've ran into quite an odd problem today. Today my app successfully got onto the app store. However, when I downloaded it I immediately noticed that the apps basic functionality wasn't working. It just hangs when trying to get outside information. I…
p0ny
  • 329
  • 1
  • 3
  • 11
1
vote
1 answer

iOS:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (_NSInlineData)'

NSData *imgData; if (!_groupImageView.image) { imgData=[NSData dataWithData:UIImagePNGRepresentation([UIImage imageNamed:@"Replay.png"])]; } else { imgData=[NSData dataWithData:UIImagePNGRepresentation(_groupImageView.image)]; } NSError…
Kiran P Nair
  • 2,041
  • 22
  • 31
1
vote
2 answers

How do I access the data when I am using NSURLSession?

I am new to iOS development. I am using Swift and I have very little experience with Objective-C, so some of the other possibly related answers are tricky to understand. I am trying to understand how to use NSURLSession to get some data from a JSON…
PrairieProf
  • 174
  • 11
1
vote
1 answer

iOS NSURLSessionConfiguration without Caching not working as intended

i am facing a security issue in iOS7. I want to make my url connection without any caching by doing the following configuration: +(NSURLSessionConfiguration *)createSessionConfig { NSURLSessionConfiguration *sessionConfig = …
Martin
  • 790
  • 2
  • 9
  • 24
1
vote
0 answers

NSHTTPURLResponse allHeaderFields is not all. Need exact response message

My server returns code 401 but in response message string it also gives description in more details (why auth might be failing) In Android I use response.Message = httpsURLConnection.getResponseMessage(); response.Code =…
katit
  • 17,375
  • 35
  • 128
  • 256