How NSNotification can be used to verify NSTask status

How can NSNotification be used to check the status of an NSTask? I know that there are several class methods in NSTask, but I don’t really understand how to implement them in a Cocoa application. Can someone help me?

+3
source share
3 answers

The job will depend on you not reading what it sends to stdout / stderr. To do this, you need to create channels and install them using setStandardOutput.

Use [NSFileHandle readToEndOfFileInBackgroundAndNotify]and wait NSFileHandleReadToEndOfFileCompletionNotification. This will give you all the data in the callback.

0
source

, NSTask, , NSNotification NSTask.

, , . SO Cocoa NSTask, w/o NSNotification

+5

, , , , , :

NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];

NSFileHandle *file;
file = [pipe fileHandleForReading];

[task launch];

NSData *data;
data = [file readDataToEndOfFile];

? jus

0

All Articles