In #144 NSURLSession instead of NSURLConnection, I mentioned that we should use the
NSURLSession family of classes as a replacement for
NSURLConnection and used the default
NSURLSessionConfiguration object in the code examples.
There are actually 3 types of
NSURLSessionConfigurations available. The default, ephemeral and background sessions, created by
The default configuration uses a shared cookie store so it is generally good for web browsing. The ephemeral session configuration uses a store that is only in-memory so it is useful for where privacy is desired. The background session is slightly different because operations using it runs in the background, and will continue running until it is completed or if the app is manually killed by the user in the task switcher.
There are two special properties that only apply to background session configurations. Setting the
discretionary property hands control over when the upload/download operations should start to the system. Setting the
sessionSendsLaunchEvents property resumes/launches the app in background when transfers are completed.