• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSData DataWithContentsOfURL within a protocol handler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData DataWithContentsOfURL within a protocol handler


  • Subject: Re: NSData DataWithContentsOfURL within a protocol handler
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 06 Sep 2012 13:44:29 -0700

On Sep 6, 2012, at 1:21 PM, Dan S <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


References: 
 >Re: NSData DataWithContentsOfURL within a protocol handler (From: danchik <email@hidden>)
 >Re: NSData DataWithContentsOfURL within a protocol handler (From: Fritz Anderson <email@hidden>)
 >Re: NSData DataWithContentsOfURL within a protocol handler (From: Jean Suisse <email@hidden>)
 >Re: NSData DataWithContentsOfURL within a protocol handler (From: Dan S <email@hidden>)
 >Re: NSData DataWithContentsOfURL within a protocol handler (From: Dan S <email@hidden>)
 >Re: NSData DataWithContentsOfURL within a protocol handler (From: Dan S <email@hidden>)

  • Prev by Date: Re: NSData DataWithContentsOfURL within a protocol handler
  • Next by Date: Re: Collision between Cocoa classes for AU and VST plugins
  • Previous by thread: Re: NSData DataWithContentsOfURL within a protocol handler
  • Next by thread: Re: NSData DataWithContentsOfURL within a protocol handler
  • Index(es):
    • Date
    • Thread