• 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: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?


  • Subject: Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
  • From: Ken Thomases <email@hidden>
  • Date: Tue, 07 May 2013 17:52:53 -0500

On May 7, 2013, at 5:37 PM, Jean Suisse wrote:

> By any chance, could a call to [[NSAttributedString alloc] initWithHTML:dataUsingEncoding:documentAttributes:] lead to the event loop being run before the call returns?

Yes, it can.  Under the hood, NSAttributedString is using WebKit for HTML rendering.  In part that means that, when invoked from a background thread, it has to shunt the work to the main thread.  But it also means the main thread may have to run the run loop during the call.  It's a nuisance, but it's necessary since HTML can have references to external resources that need to be loaded.

Consider the other method, -[NSAttributedString initWithHTML:options:documentAttributes:] and its options dictionary, which can have keys like NSTimeoutDocumentOption and NSWebResourceLoadDelegateDocumentOption.  Those imply a pretty involved process under the hood.  I'm fairly certain that this method is used for the implementation of the method you're using.

You may be able to use those options to minimize the use of the run loop, but probably not eliminate it.

Regards,
Ken


_______________________________________________

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

  • Follow-Ups:
    • Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
      • From: Jens Alfke <email@hidden>
    • Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
      • From: Jean Suisse <email@hidden>
References: 
 >Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop? (From: Jean Suisse <email@hidden>)

  • Prev by Date: Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
  • Next by Date: Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
  • Previous by thread: Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
  • Next by thread: Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
  • Index(es):
    • Date
    • Thread