• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Which class methods return autoreleased objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Which class methods return autoreleased objects? (From: Jeremy French <email@hidden>)
 >Re: Which class methods return autoreleased objects? (From: Ricky Sharp <email@hidden>)
 >Re: Which class methods return autoreleased objects? (From: Paul Sargent <email@hidden>)

  • Prev by Date: Re: Which class methods return autoreleased objects?
  • Next by Date: Re: Allocate memory for object
  • Previous by thread: Re: Which class methods return autoreleased objects?
  • Next by thread: Re: Which class methods return autoreleased objects?
  • Index(es):
    • Date
    • Thread