Re: using AppKit additions in background threads
Re: using AppKit additions in background threads
- Subject: Re: using AppKit additions in background threads
- From: Douglas Davidson <email@hidden>
- Date: Tue, 6 Sep 2011 12:23:27 -0700
On Sep 6, 2011, at 11:53 AM, Jens Alfke wrote:
> On Sep 6, 2011, at 11:11 AM, Michael Thon wrote:
>
>> Yup, they're HTML, all right. Now I'm thinking of moving this code to a separate command line app that I can call from the main application. It should work, but I'm not sure if I'd need to provide a runloop for the HTML importing to work.
>
> The background tool will need to link against WebKit and AppKit, so it won’t be strictly-speaking ‘background’. You can mark its bundle with a special key (LSBackgroundOnly?) to keep it from showing up in the Dock or getting a menu-bar though.
>
> The bigger problem is how this tool sends results back to the main app. An NSAttributedString is an in-memory object, and the tool has a separate address space. I guess you could try archiving the string and sending back the data, but I’m not sure whether all the different attribute values used in parsed HTML are archivable.
>
> What do you use the attributed string for, if this is a background-only operation? Maybe there’s a less expensive way to accomplish it.
One possibility would be to convert the HTML to RTF or RTFD, which could be loaded in the background. For that sort of conversion we already have a tool on the system, /usr/bin/textutil. There are also other potential methods for parsing HTML, if the intent is for something other than full editable rich text support.
Douglas Davidson
_______________________________________________
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