Re: Associating context with background NSURLSession tasks
Re: Associating context with background NSURLSession tasks
- Subject: Re: Associating context with background NSURLSession tasks
- From: Rick Mann <email@hidden>
- Date: Mon, 09 Feb 2015 20:12:43 -0800
Hmm. In partial answer to my own question, the taskIdentifier cannot be used, because it seems to restart every session.
I guess I could put something in the taskDescription, but that's documented as being human-readable.
> On Feb 9, 2015, at 17:37 , Rick Mann <email@hidden> wrote:
>
> It seems that the NSURLSession API is missing a very important piece: a mechanism for associating context with a background task.
>
> With my NSURLConnection-based code, I essentially created a generic delegate for each connection, which was responsible for invoking blocks for the various connection events. The blocks then captured the necessary context.
>
> But with a background session, my app may be re-launched and have no in-memory context, so I need to resurrect that context from the NSURLSession and tasks API. I can't set the identifier of tasks (as far as I can tell), but I suppose I could use the provided task identifier, if it's guaranteed to be unique even after a task is complete.
>
> Here's the thing. I'll have to persist that identifier along with enough information to reconstruct my context. If NSURLSession re-uses those identifiers, then I won't be able to reliably reconstruct the correct context.
>
> Suggestions? Thanks,
>
> --
> Rick Mann
> 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
--
Rick Mann
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