Re: Reading data from an NSTask
Re: Reading data from an NSTask
- Subject: Re: Reading data from an NSTask
- From: j o a r <email@hidden>
- Date: Mon, 4 Jul 2005 19:06:21 +0200
On 4 jul 2005, at 18.50, Ken Tozier wrote:
I created an NSTask to run nibtool and am seeing the result in the
run log, but so far haven't had any luck at pulling the data out of
the task. Anyone see the problem in the below snippet?
NSTask *testTask1 = [NSTask launchedTaskWithLaunchPath:
@"/usr/bin/nibtool"
arguments: [NSArray
arrayWithObjects: @"-a", @"/Users/kentozier/Desktop/TestNib.nib",
nil]];
// if I step through in the debugger, it hangs on the next line.
// The run log however shows that the nib data exists somewhere as
it get printed.
NSData *test1Data = [[testTask1 standardOutput]
readDataToEndOfFile];
NSString *testString = [[NSString alloc] initWithData: test1Data
encoding: NSUnicodeStringEncoding];
// the code never seems to make it to here
NSLog(@"standard output = %@", testString);
The problem is probably that you don't empty the buffer in the queue
between the processes. When the buffer is full it just hangs, waiting
for you to make more space until it can continue. This is something
of a FAQ, something should be added to the standard documentation to
better explain that this can happen, and a suggested implementation
for handling it. There is information about this in the list
archives, but it can be a bit tricky to find. Perhaps this will do:
<http://www.cocoabuilder.com/archive/message/cocoa/2003/12/29/78363>
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden