Questions tagged [urlsession]

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

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

A URLSession 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. URLSession provides status and progress properties, of which support canceling, resuming, or suspending tasks, and resuming suspended, canceled, or failed downloads.


Types of Sessions

URLSession 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.

785 questions
-2
votes
1 answer

swift3 getting Initialization of immutable value 'task' was never used on URLSession.shared.dataTask(with: url!)

I'm a newbie to Swift. I'm trying to simply read in a web page and I am getting the error "Initialization of immutable value 'task' was never used; consider replacing it with assignment to '_' or removing it" error on the "let task = " statement. …
CMan
  • 71
  • 1
  • 7
-3
votes
1 answer

Json parsing using URLSession not working

Iam getting an error while i try to send the POST request in swift 3. Any one please suggest me the correct syntax for URLSession.shared method in swift 3. this is what i tried. iam new here. let task = URLSession.shared.dataTask(with: request,…
ohm patel
  • 13
  • 5
-4
votes
1 answer

Example of URLProtocol usage?

I'm trying to figure out how URLProtocol works. Can you provide some cases of URLProtocol usage? What type of problems can it solve?
Alex Yapryntsev
  • 589
  • 6
  • 19
-9
votes
2 answers

Get Current Progress from URLSession.shared.dataTask

I need to get current progress (received and total bytes) of the data task for GET request to make a progress loading indicator from this data.
F. Sviatoslav
  • 55
  • 1
  • 9
1 2 3
52
53