Why should you use NSURLSession
? Well, it brings
you a number of new advantages and benefits:
NSURLSession
is
created, you get all the benefits of background networking. This helps with battery life, supports UIKit multitasking and uses the same delegate model as in-process transfers.NSURLSession
is
the configurable container for putting requests into. For example, if you need to set an HTTP header option you will only need to do this once and each request in the session will have the same configuration.NSURLSession
is
subclassable and you can configure a session to use private storage on a per session basis. This allows you to have private storage objects outside of the global state.
Improved authentication handling: Authentication is done on a specific connection basis.
When using NSURLConnection
if an authentication
challenge was issued, the challenge would come back for an arbitrary request, you wouldn’t know exactly what request was getting the challenge. WithNSURLSession
,
the delegate handles authentication.
ios7新特性nsurlsession初探,布布扣,bubuko.com
原文:http://blog.csdn.net/openglnewbee/article/details/38021935