When to create a new NSURLSession?

What are the best methods for reusing NSURLSessions ? From what I can say, it seems that as long as the configuration (timeouts, caching policies, etc.) does not need to be changed, there is no need to create a new one (since you can create new tasks from it).

So, is it possible to use one NSURLSession for the whole application? To domain / endpoint? On request?

+6
source share
1 answer

Execute documents. In particular, " Like most network APIs, the NSURLSession API is highly asynchronous. "

You can always create a network class that specifically processes your entire network for the application. Therefore, reuse is not only an option, but also recommended.

https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSession_class/

This is pretty good here, which explains the differences between NSURLSession and NSULConnection for a better understanding of the intended use.

+1
source

Source: https://habr.com/ru/post/985127/


All Articles