Nsurlconnection
An NSURLConnection is the Apple Foundation Framework class that provides support to perform the loading of a URL request
Nsurlsession
NSURLSession is the API for HTTP connections introduced in iOS 7 and OS X 10.9.
Others
Example |
---|
Nsurlsession is much more powerful tool than nsurlconnection from question How to receive list of binaries from server in iOS |
Nsurlconnection cannot help you there;nsurlsession has a facility for uploading files in the background outside of that time from question Does NSUrlSession Prevent the Application from suspending? |
Nsurlsession is newer than nsurlconnection if you are using swift language then you can use your own custom methods by using nsurlsession or you can use alamofire from question Which is easy to use Afnetworking/Nsurlsession/Alamofire |
Nsurlconnection is a much older api introduced in os x 10.2;nsurlsession was introduced in os x 10.9 and has a more modern task- and block-based api from question Exact Difference between NSURLConnection and NSUrlSession? |
Nsurlsession also provides nicer interfaces for requesting data using blocks in that it allows you to combine them with delegate methods for doing custom authentication handling redirect handling etc. whereas with nsurlconnection if you suddenly realized you needed to do those things you had to refactor your code to not use block-based callbacks from question What are the difference among NSURLConnection, NSURLSession and AFNetworking? |
A bit of history before nsurlsession came out a third party library afnetworking became the de facto standard for doing networking in objective c as it provided an easier and more convenient api than nsurlconnection which it was a wrapper around - i think these days it wraps nsurlsession instead from question What is the advantage of using Alamofire over NSURLSession/NSURLConnection for networking? |
It s not my experience that nsurlsession is any slower than nsurlconnection is from question Network iOS : Background / MainThread? |
Using completionhandler -based methods of nsurlsession is much easier from question Using NSURLSession to POST, what is the correct way to post the variables? |
Use nsurlsession instead;it replaces nsurlconnection and is far better from question Swift NSURLConnection deprecated in iOS 9.0 |