On Sep 6, 2012, at 1:21 PM, Dan S <danc...@rebelbase.com> wrote:

> I can return from
> the routine without completing the request, while the caller will be kept
> blocked on that request untill I respond with URLProtocolDidFinishLoading

Well, the caller probably won’t be blocked, since it should be using an async 
API. But that doesn’t matter to you as the protocol.

> Except can I get a confirmation please that the client using the protocol
> handler will not reuse it untill request is completed (i.e. it wont use the
> same instance to make another request once I return from -startLoading,
> untill it gets a completion like a final redirect or
> URLProtocolDidFinishLoading)??

An instance is only ever used once, for a single request.

> So, following your suggestion, to avoid calling URLProtocolDidFinishLoading 
> from the thread, what would be preferable for calling it from main thread? 
> performSelectorOnMainthread or listening to threadWillTerninate notification? 
> or something else?

If you just use the asynchronous API from your protocol handler, the delegate 
callbacks will all happen on the same thread, so you don’t have to worry about 
threading at all.

If you want to run your loading on a separate thread, you’ll need to remember 
the identity of the thread that -startLoading was called on (it is not the main 
thread) and call the client on that thread. You can use 
-performSelector:onThread:withObject:waitUntilDone: to do this.

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to