FROM : Randall Meadows
DATE : Thu May 15 20:49:43 2008
On May 15, 2008, at 12:42 PM, ben syverson wrote:
> I have a bit of a dilemma. I'm working on a Foundation-based command-
> line utility that needs to manage a few threads. The obvious choice
> is NSThread, since it's nice and clean.
>
> Actually, I'm able to spawn new threads perfectly well. The problem
> is that I can't (?) use performSelectorOnMainThread: because I'm not
> an NSApplication, and so I don't get the default "main" thread that
> loops for user input...
>
> Am I busted? I would like to be able to run this app without the
> window server running (ie, in Single User Mode), because it's server
> software.
>
> I can always fall back to POSIX threads, but I'd rather use NSThread
> if possible. Is there an alternate way to have my spawned NSThreads
> call back to a controller thread (that doesn't require 10.5)?
Can't you cache the main thread [NSThread +currentThread] when you
start up, and then use NSObject's -
performSelector:onThread:withObject:waitUntilDone: method?
DATE : Thu May 15 20:49:43 2008
On May 15, 2008, at 12:42 PM, ben syverson wrote:
> I have a bit of a dilemma. I'm working on a Foundation-based command-
> line utility that needs to manage a few threads. The obvious choice
> is NSThread, since it's nice and clean.
>
> Actually, I'm able to spawn new threads perfectly well. The problem
> is that I can't (?) use performSelectorOnMainThread: because I'm not
> an NSApplication, and so I don't get the default "main" thread that
> loops for user input...
>
> Am I busted? I would like to be able to run this app without the
> window server running (ie, in Single User Mode), because it's server
> software.
>
> I can always fall back to POSIX threads, but I'd rather use NSThread
> if possible. Is there an alternate way to have my spawned NSThreads
> call back to a controller thread (that doesn't require 10.5)?
Can't you cache the main thread [NSThread +currentThread] when you
start up, and then use NSObject's -
performSelector:onThread:withObject:waitUntilDone: method?






Cocoa mail archive

