Re: NSTask and Notification?
Re: NSTask and Notification?
- Subject: Re: NSTask and Notification?
- From: "Alastair J.Houghton" <email@hidden>
- Date: Fri, 24 Oct 2003 15:24:31 +0100
On Friday, October 24, 2003, at 02:50 pm, David Dauer wrote:
When using pipes, you should always read all of the output from the
process as it arrives, which is what the code David sent appears to
do.
Looking at the code, I would expect to get more than one alert panel
on the screen if the process you started in your NSTask outputs any
substantial amount of data, because you continue to call
-readInBackgroundAndNotify as long as you are receiving data.
And *how* can i solve that problem?
I want use notifications, because the user should be able to work with
my program as long as the task gives
output. How can i detect when the task don't print anything more so
that i can procceed the final output with a function?
When you get a notification with zero bytes of data, there won't be any
more (it does say this in the documentation, if you follow the link
from -readInBackgroundAndNotify to -availableData).
You actually already check for this case in your code, although you
need to move the call to -readInBackgroundAndNotify inside your "if
([data length]) {" statement and add an else to the end of your if.
Something like:
- (void)getOutput:(NSNotification *)aNotification
{
...
if ([data length]) {
/* Process data */
[toolStdout readInBackgroundAndNotify];
} else {
/* Finished */
}
}
Kind regards,
Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.