NSURLSessionTasks don't have their own delegates?!
NSURLSessionTasks don't have their own delegates?!
- Subject: NSURLSessionTasks don't have their own delegates?!
- From: Jens Alfke <email@hidden>
- Date: Tue, 22 Jul 2014 09:03:41 -0700
I just realized to my horror that NSURLSessionTask doesn’t have a delegate property. That means, unless I’ve missed something, that _all_ the delegate calls for all tasks in a session get funneled through the single NSURLSession delegate? Really?!
I’ve been using NSURLConnection since 2003 or so and I’ve _never_ used a single global delegate. The obvious OO pattern is to create an object for each task at hand, and make it the delegate of the NSURLConnection it invokes. You generally need to maintain state per request anyway (like the data downloaded, or the status, or the eventual model object that’s going to want the received data) so you want an object to put that in. If all the delegate calls now go to a single place, I’m going to have to write even more code to keep track of all my active tasks and route each delegate call to its relevant owner.
I’m getting the impression that the NSURLSession API was designed explicitly to screw with people who’ve already been using NSURLConnection. :(
(Sorry, this isn’t a question. Unless maybe it’s “Am I reading this wrong? Do my eyes deceive me?”)
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden