Re: NSSavePanel called from BSD application - no keyboard input
Re: NSSavePanel called from BSD application - no keyboard input
- Subject: Re: NSSavePanel called from BSD application - no keyboard input
- From: Kevin Martin <email@hidden>
- Date: Tue, 10 Feb 2009 21:51:23 +0000
On 10 Feb 2009, at 20:26, Kyle Sluder wrote:
Just because it's there doesn't mean you have to use it. Granted,
we're talking about blocking I/O in the context of an application,
which needs to be pumping its runloop, but you can continue to use
read(2) and write(2) without NSPipe, as long as you play nice with the
runloop.
I've been reading a little more of the API and this is what I have now
figured for the wrapper application.
1) Create a pipe for stdin and stdout of the console application.
2) Create a new thread, set up the pipes appropriately and call the
console application's entry point (I have sources so can just compile it
in)
2) I can monitor the stdout pipe with NSFileHandle's
waitForDataInBackgroundAndNotify. I don't know how to receive the
notification at the moment, but it shouldn't be too hard.
3) I'm pretty sure NSFileHandle's writeData will block if the process on
the other end of the pipe doesn't read it. But I can launch a new thread
or use an NSOperation or something like that, just in case the console
app isn't listening when the user wants to send input.
4) When the console application calls FileChooser::runSaveDialog I can
use NSObject's performSelectorOnMainThread:withObject:waitUntilDone:
selector On an appropraite object to run the dialog. This is very very
cool.
I've been reading Aaron Hillegass's book and there is a quote in there
that says something like
"If you feel you are fighting the API, you're doing it wrong"
Everything so far has felt like I was fighting the API, this feels
like the
right way to do it.
Thanks,
Kevin Martin
_______________________________________________
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