RE: Memory management in a thread
RE: Memory management in a thread
- Subject: RE: Memory management in a thread
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Fri, 12 Mar 2004 16:00:14 -0500
>
At 3:02 PM -0500 3/12/04, Jonathan E. Jackel wrote:
>
>
>First, there's no rule that says you have to use autoreleased
>
objects. You
>
>can retain objects and release them immediately when you are done.
>
>
Let's say I receive a reply to an AppleEvent; I create an NSString
>
from the reply text using [NSString stringWithCString:]; I now have
>
an autoreleased NSString that contains tab-delimited text; if I call
>
[data componentsSeparatedByString:@"\t"] to get an NSArray *, that
>
array is autoreleased as well, right? I don't own either the string
>
nor the array, so I can't release them. This is how I'm getting most
>
of the references I'm using. Isn't this "forcing" me to use
>
auto-released objects?
No. You chose to use +stringWithCString instead of -initWithCString (both
of which are deprecated, by the way). You also chose to
use -componentsSeparatedByString instead of parsing the string yourself into
strings that you have allocated. I'd probably do the same, but I wouldn't
say I had been forced to, any more than I'm forced to eat Girl Scout cookies
that are suboptimally minty. I could make my own, mintier version, but
come on, that would take at least $100 of my time to improve on a $4 box of
cookies. So I suffer in silence.
Jonathan
_______________________________________________
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.