NSURLSession class Hierarchy
- NSURLSession – First we need to create object of NSURLSession class i.e A Session Object.
- NSURLSessionConfiguration – A Configuration object used when initializing the object.
- NSURLSessionTask – A base class for within a session. >>NSURLSessionDataTask – A Task for retrieving a contents of a URL as anNSData Object >NSURLSessionUploadTask – A Task for uploading a file, then retrieving the contents of a URL as an NSData Object >>NSURLSessionDownloadTask – A task for retrieving the content of a URL as a temporary file on disk.
- NSURLSession API provide 4 protocol,that define delegate method for your app to more option to session task
- NSURLSessionDelegate – Define the delegate method to handle session-level events
- NSURLSessionTaskDelegate – Define the delegate method to handle task-level events common to all task type.
- NSURLSessionDataDelegate – Define delegate method to handle task-level events specific to data and upload task
- NSURLSessionDownloadDelegate – Define delegate method to handle task – level specific to download content
- NSURLSession need this class also. (1) NSURL – Create object type of NSURL (2) NSURLRequest – Encapsulate metadata related to a URL request. including the URL, request method, and so on. (3) NSURLResponse – Encapsulate metadata related to a servers response’s to a request such as the content MIME (Multi-Purpose Internet Mail Extension) type and length . (*3) NSHTTPURLResponse – Add additional metadata specific to HTTP request. (4) NSCachedURLResponse – Encapsulate NSURLResponse object, along with the actual body data of the server’s response for caching purpose.
- For More Information Please Visit
 |
| NSURLSession Class |
Why NSURLSession
- The NSURLSession Class and related classes provide an API (Application Interface Programming) for downloading content by way of HTTP(Hypertext Transfer Protocol).
- This API provide rich set of delegate method for supporting authentication and gives ability to your app performing Background download when your app is not running.
- If your app suspend then also NSURLSession rich delegate method ability to background run or download.
- NSURLSession API,your app create a series of session,each of which coordinates a group of related task.
- in Session there are three types of configuration object.
- 1) default sessions 2) ephemeral sessions 3) download sessions
- default session load the contents of a URL by providing a URL request object. You perform most of your configuration on the URL request object itself. default sessions that behave much like NSURLConnection.
- ephemeral session that do not cache anything to disk.
- download session that store the result in file and continue data even when your app is suspended,exits or crash.
- within session,you can schedule three type of task.
- 1) data tasks 2) download tasks 3) upload task
- data tasks for retrieving data to memory, download tasks for downloading file to disk, upload task for uploading a file from disk and receiving the response as data in memory.
- For More Information Please Visit
 |
| NSURLSession |