On 10 Feb 2015, at 01:37, Rick Mann <[email protected]> wrote:

> It seems that the NSURLSession API is missing a very important piece: a 
> mechanism for associating context with a background task.

I solve this problem by using the quite-obscure +setProperty:forKey:inRequest: 
and +propertyForKey:inRequest: methods on NSURLProtocol.  I create a unique ID 
for my request, assign that to a property on the request, and then create the 
task from that.  As long as you use a property that supports NSSecureCoding on 
both sides of the 'wire' [1], that property persists with the task across 
relaunches of your app.  To keep things simple I typically use a string.

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

[1] That is, both your app and the NSURLSession background session daemon.


 _______________________________________________
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]

Reply via email to