TL;DR Is there any common pattern of using NSURLSession
in whole application by simply creating a new client class just the way you subclass AFHTTPSessionManager
?
I like to use AFNetworking
for many reasons and if I see no contraindications I use it with a pleasure but sometimes I've got a relatively simple task to achieve and AFNetworking
seems to be an overkill or I simply need to avoid third party dependencies.
With that in my mind I realise that guys from Apple provided us with a cool thing called NSURLSession
and it sounds like a perfect soultion for many cases but when I star reading about using it in projects, well I want to get back to AFNetworking
let me explain why...
When you plan to create a custom class for your networking task using AFNetworking
you simply create a subclass of AFHTTPSessionManager
(of course if you're dealing with HTTP) and simply return singleton and so on... (If you don't know the rest of the story, check this great tutorial)
Simple, right?
But what if I want to subclass NSURLSession
in the same way? Well, I'm still searching the Internet for a solution but so far no luck here... Every tutorial, every article, every post state that you instantiate NSURLSession
in your view controller and if needed you use it, period. But what happend in case I want to use this client throughout my whole application?