On Sep 6, 2012, at 11:25 AM, Dan S <danc...@rebelbase.com> wrote:

> I will try to offload the server access to a different thread (though I
> still need to block the protocol thread because I still have to return the
> correct data for the current call).

No — as I said before, you should _never_ block the protocol-handler thread.

I think you’re misunderstanding how NSURLProtocol works. When your 
-startLoading method is called, it does not have to send a response to the 
client immediately. Unless you have data already available (unlikely in your 
case) you should just kick off your own async request for the data, and then 
immediately return. Later on as the data arrives, you can call your client with 
the response and data. After everything’s done, call the client’s 
URLProtocolDidFinishLoading:. (The only restriction seems to be that you must 
call the client from the protocol-handler thread, i.e. the same thread 
-startLoading was called on. I’ve tried to do otherwise and it didn’t work 
well.)

—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