Re: Multi-threaded AppKit examples?
Re: Multi-threaded AppKit examples?
- Subject: Re: Multi-threaded AppKit examples?
- From: Finlay Dobbie <email@hidden>
- Date: Mon, 28 Jan 2002 18:57:59 +0000
On Monday, January 28, 2002, at 12:35 PM, Fraser Speirs wrote:
I'm working on a cocoa app where we periodically request data from
another application (specifically, the current song in iTunes) via
Applescript. The way we do it is by invoking /usr/bin/osascript via
NSTask. This is slow and at the moment we do it in the UI thread,
leading to barely-acceptable responsiveness to the user.
I understand that I should use Distributed Objects to communicate
between the threads, but I'm kind of stuck with actually passing data
back and forth. It's just an NSString I want to return to the AppKit
thread to fill in a text field. I've looked at the examples on
developer.apple.com.
Seen the TrivialThreads example code? If not, look there. Anyway, if
you're reading data from an NSTask, you might find -[NSFileHandle
readInBackgroundAndNotify] easier than initialising your own
inter-thread communications pipe.
-- Finlay