Re: Reading data from an NSTask [SOLVED]
Re: Reading data from an NSTask [SOLVED]
- Subject: Re: Reading data from an NSTask [SOLVED]
- From: Ken Tozier <email@hidden>
- Date: Mon, 4 Jul 2005 20:53:50 -0400
On Jul 4, 2005, at 8:27 PM, mmalcolm crawford wrote:
On Jul 4, 2005, at 4:11 PM, Ken Tozier wrote:
NSTask *testTask = [[NSTask alloc] init];
autorelease?
Yeah. That would be better.
NSTask *testTask = [[[NSTask alloc] init] autorelease];
NSLog(@"task failed with error = %@", [[NSString alloc]
initWithData: taskData encoding: NSUnicodeStringEncoding]);
This also leaks. It also seems "risky" if, say, the data size is
in the megabyte range and fails just before completion. Moreover,
the string encoding may well be something other than Unicode...
Since both testTask's "standardOutput" and "standardError" point to
the same fileHandle, wouldn't an error flush the handle? I'm not very
familiar with how the unix tools do stuff.
Re Unicode: That is wrong (at least for errors) it should be
"NSUTF8StringEncoding." Saw that after pressing the send button.
Would this be better, risk-wise?
NSString *errMsg = [[NSString alloc] initWithData:
taskData encoding: NSUTF8StringEncoding];
NSLog(@"task failed with error = %@", errMsg);
[errMsg release];
_______________________________________________
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