What is the main difference between NSURLSession and NSURLConnection ?
1 min readOct 12, 2021
- While using NSURLConnection , when App goes into background mode or not running mode , everything we have receive and sent were lost.
- NSURLSession API gives you the ability to perform background download when the app is not running or app is suspended or in background.
- The NSURLSession API provides support for download tasks that behave much like the NSURLDownload class.
- NSURLSession object, you provide a reusable configuration object that encapsulates many common configuration options. With NSURLConnection, you must set those options on each connection independently.
- An NSURLConnection object handles a single request and any follow-on requests. An NSURLSession object manages multiple tasks, each of which represents a single URL request and any follow-on requests.
- With NSURLConnection, each connection object has a separate delegate. With NSURLSession, the delegate is shared across all tasks within a session. If you need to use a different delegate, you must create a new session.