Re: Which class methods return autoreleased objects?
Re: Which class methods return autoreleased objects?
- Subject: Re: Which class methods return autoreleased objects?
- From: Clark Cox <email@hidden>
- Date: Sat, 11 Dec 2004 07:39:36 -0500
On Sat, 11 Dec 2004 11:20:24 +0000, Paul Sargent <email@hidden> wrote:
>
[snip]
>
> NSArray * returnArray = [NSArray arrayWithArray:curveArray];
> return returnArray;
> }
>
> Now here's how I currently understand things. Please correct me if I'm
> wrong.
>
> returnArray is an autoRelease'd object.
> There's no local autoRelease pool, so it will survive the end of the
> function call.
> It will have been created in the parent's autoReleasePool scope, as
> will all the local objects.
> Therefore it's suitable for passing back.
Correct.
> P.S. Is there a better way to convert a mutable array to an immutable
> array than [NSArray arrayWithArray:]?
Not necessarily "better", but different (The end result is the same):
[[curveArray copy] autorelease]
Offhand, I can't think of any reason to choose one over the other.
--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
_______________________________________________
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