Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?
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