Skip navigation.
 
mlRe: Which class methods return autoreleased objects?
FROM : Clark Cox
DATE : Sat Dec 11 13:39:36 2004

On Sat, 11 Dec 2004 11:20:24 +0000, Paul Sargent <<email_removed>> 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_removed>
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/

Related mailsAuthorDate
mlWhich class methods return autoreleased objects? Jeremy French Dec 6, 22:36
mlRe: Which class methods return autoreleased objects? Nick Zitzmann Dec 7, 00:15
mlRe: Which class methods return autoreleased objects? Ricky Sharp Dec 7, 00:16
mlRe: Which class methods return autoreleased objects? Gwynne Dec 7, 00:59
mlRe: Which class methods return autoreleased objects? M. Uli Kusterer Dec 7, 05:00
mlRe: Which class methods return autoreleased objects? Charlton Wilbur Dec 7, 05:43
mlRe: Which class methods return autoreleased objects? Scott Anguish Dec 7, 06:30
mlRe: Which class methods return autoreleased objects? Paul Sargent Dec 11, 12:20
mlRe: Which class methods return autoreleased objects? Clark Cox Dec 11, 13:39