Fwd: stdout redirect in xcode and not
Fwd: stdout redirect in xcode and not
- Subject: Fwd: stdout redirect in xcode and not
- From: email@hidden
- Date: Wed, 24 Dec 2008 08:52:32 -0500
On Dec 24, 2008, at 1:42 AM, Wesley Smith wrote:
In the end, I had to use a polling method as I couldn't find any way
to get callbacks when a pipe has data to read off the read endpoint.
I've done something similar where I created a pipe and exec'ed a
subtask. Did you try this:
NSFileHandle *readPipeHandle = [NSFileHandle alloc]
initWithFileDescriptor:pipe[0]];
[readPipeHandle setDelegate: self];
[readPipeHandle waitForDataInBackgroundAndNotify];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(logDataAvailableCallback:) name:
NSFileHandleDataAvailableNotification object:readPipeHandle];
.
.
.
- (void) logDataAvailableCallback:(NSNotification *)notif
{
NSFileHandle *handle = [notif object];
NSData *data = [handle availableData];
...
[handle waitForDataInBackgroundAndNotify];
}
Even better, for getting the pipe handle:
NSPipe *pipe = [NSPipe pipe];
NSFileHandle *readPipeHandle = [pipe fileHandleForReading];
Aaron
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden