There isn’t a way to do this directly. Most folks don’t need to do this because they have a limited set of sessions, with each session having its own unique purpose. Thus, when dealing with a task you already know the context necessary to find its session.
If you’re dealing with an arbitrary mix of sessions and tasks, you could solve this problem by tagging each task with an identifier for looking up the session.
taskDescription
is a good way to do this [1]. Another option is to associate a custom value with the task’s request using the
URLProtocol
property APIs,
setProperty(_:forKey:in:)
and friends.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
[1] The documentation indicates that this is intended to be a user-visible value but that’s not actually the case. I’m going to go fix that now (q. 128150).