nsurlsession VS nsurlconnection
Nsurlsession can be seen as an evolutionary version of Nsurlconnection, and its improvements to Nsurlconnection are:
- * Configure on a per session basis (HTTP header,cache,cookie,protocal,credential) and no longer share configurations across the app level.
- * Support for network operation cancellation and breakpoint continuation
- * Improved handling of authorization mechanisms
- * A rich delegate model
- * Separation of real data and network configuration data.
- * Background processing upload and download, even if you click on the "Home" button, the background can still continue to download, and provides a configuration based on the network condition, the power situation to handle.
Knowledge points
usage
The general routines for using Nsurlsession are as follows:
- 1. Define a Nsurlrequest
- 2. Define a nsurlsessionconfiguration, configure various network parameters
- 3. Use Nsurlsession's factory method to obtain a desired type of nsurlsession
- 4. Use defined Nsurlrequest and nsurlsession to build a nsurlsessiontask
- 5. Use delegate or Completionhandler to handle all events of the task execution process.
IOS nsurlsession VS nsurlconnection