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/
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 mails | Author | Date |
|---|---|---|
| Jeremy French | Dec 6, 22:36 | |
| Nick Zitzmann | Dec 7, 00:15 | |
| Ricky Sharp | Dec 7, 00:16 | |
| Gwynne | Dec 7, 00:59 | |
| M. Uli Kusterer | Dec 7, 05:00 | |
| Charlton Wilbur | Dec 7, 05:43 | |
| Scott Anguish | Dec 7, 06:30 | |
| Paul Sargent | Dec 11, 12:20 | |
| Clark Cox | Dec 11, 13:39 |






Cocoa mail archive

