hehe, yes thank you, I was definatelly treating -startLoading it as the end
all call.  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?

and should I assume that the initial -startLoading came from the main
thread or should I poll for which thread it came from and performSelector
on that thread (in which case am I guaranteed that that particular thread
is still running if it is not main)?

On Thu, Sep 6, 2012 at 1:19 PM, Jens Alfke <j...@mooseyard.com> wrote:

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