On 28 Jan 2015, at 01:50, Greg Robbins <[email protected]> wrote:
> What's an appropriate granularity for reusing an NSURLSession object?
It's mostly up to you. The only approach that I specifically advise against is
"one session per task", which is needlessly wasteful. Sessions are supposed to
be relatively long-lived objects. Which means...
> 2. Is there value to reusing a session for as long as an app is running, or
> to invalidating a session when an app is not making network requests?
It's perfectly reasonable to create a session when you app launches and keep it
around for the lifetime of your app.
* * *
Off the top of my head I can see three really good reasons for using multiple
sessions:
o You have multiple entities within the process and you want their requests to
be separate. The obvious use case here is for frameworks, where the framework
developer wants their requests to be separate from those requests issued by the
app and by other frameworks.
o You have requests with very different characteristics, characteristics that
are controlled by the session configuration. For example, you want some
requests to use the system proxy settings (if any) and some to use your custom
proxy.
o You're using background session support.
I'm sure there are other good reasons as well.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com
This email sent to [email protected]