Can I make a session object whenever I need with different configurations or is there any constraint on creating session objects?
Asked
Active
Viewed 453 times
1 Answers
1
There are no constraints on creating session objects. In fact, the documentation clearly encourages creating additional sessions for handling requests with the same session configuration:
With the NSURLSession API, your app creates one or more sessions, each of which coordinates a group of related data transfer tasks. For example, if you are writing a web browser, your app might create one session per tab or window, or one session for interactive use and another session for background downloads.
This, of course, does not imply that you should create a separate session for each and every request you make.

Dmitry Serov
- 861
- 11
- 22
-
Thanks for the reply.. Looking forward for some more answers.. If none I'll mark your answer as correct. :) – jegadeesh Jul 17 '17 at 12:50
-
1The only constraints I know of are that A. each session consumes some memory, and B. limits on the number of simultaneous connections per host are IIRC per session, so you should generally use a small number of sessions and override various behaviors in the NSURLRequest where possible. – dgatwood Jul 18 '17 at 14:59