Have you thought about doing this as an
NSURLProtocol
subclass? That lets you avoid networking entirely, which is going to make for easier and more efficient code.
Be aware that with
NSURLSession
the app has to explicitly opt in to your
NSURLProtocol
via the
protocolClasses
property. So this approach won’t work if the app doesn’t have control over the session, for example, if it’s using some higher-level API that’s wrapped around
NSURLSession
.
The best place to start with
NSURLProtocol
is the
CustomHTTPProtocol sample code.
IMPORTANT Much of the complexity of that sample centres around the recursive dispatch, and that’s something you don’t need because you’re dispatching down to your EA code.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
—
WWDC runs Mon, 4 Jun through to Fri, 8 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face.