Re: Reading return values from NSTask
Re: Reading return values from NSTask
- Subject: Re: Reading return values from NSTask
- From: Shawn Erickson <email@hidden>
- Date: Mon, 29 Dec 2003 21:25:25 -0800
On Dec 29, 2003, at 9:16 PM, KLW wrote:
Shawn,
Thanks for your help, as well as for pointing out some of the memory
allocation and initialization flaws in my code. I have assigned myself
the task on rereading those sections in my two books. I still feel
quite lost on that subject.
Glad I could help.
[snip]
data = [[[perlControl standardOutput] fileHandleForReading]
availableData];
if ((data != nil) && [data length]) {
result = [[[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding] autorelease];
}
[data release];
[snip]
You do not need to release data since you didn't allocate it (you
didn't use alloc, copy or mutableCopy). I bet that is causing your
crash later in your application when the current autorelease pool is
deallocated.
Cheers,
-Shawn
_______________________________________________
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.