Re: NSURLSessionTasks don't have their own delegates?!
Re: NSURLSessionTasks don't have their own delegates?!
- Subject: Re: NSURLSessionTasks don't have their own delegates?!
- From: Shawn Erickson <email@hidden>
- Date: Tue, 22 Jul 2014 12:16:09 -0400
Oops sent to early, basically sessions align more closely with connections of old.
Also the block based aspect allows tasks to fire against their own completion logic so no delegate is needed at the task level (unless doing special processing).
> On Jul 22, 2014, at 12:09 PM, Shawn Erickson <email@hidden> wrote:
>
> In my experience you just create multiple session objects per thing needing tasks executed.
>
> -Shawn
>
>
>
>
>> On Jul 22, 2014, at 12:03 PM, Jens Alfke <email@hidden> wrote:
>>
>> 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
_______________________________________________
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