• 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: Trying to understand -- please help...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to understand -- please help...


  • Subject: Re: Trying to understand -- please help...
  • From: Andy Lee <email@hidden>
  • Date: Thu, 22 May 2008 18:02:00 -0400

On May 22, 2008, at 5:13 PM, Johnny Lundy wrote:
My point in using that class reference was simply to show how someone could follow the "manual" and still have his code not work.

Actually, the "introductory documentation" never actually says that the convenience constructors always return autoreleased objects -- it just says that they "in general" do (paraphrasing).

Even more reason, IMO, for the Class Reference to explicitly say what the class does with the returned objects.

The way it is written, the objects are retained; so one should conclude that they are not autoreleased.

To be clear: by "it," do you mean the NSArray documentation you mentioned earlier? I meant to mention something about that:



On May 21, 2008, at 2:35 PM, Johnny Lundy wrote:
To make it even more demonstrative of what I have been saying about the documentation, here's the excerpt of the "Overview" section in NSArray Class Reference dealing with retain-release of NSArrays:

Generally, you instantiate an array by sending one of the array... messages to either the NSArray orNSMutableArray class object. These methods return an array containing the elements you pass in as arguments. (Note that arrays can’t contain nil.) In general, objects that you add to an array aren’t copied; rather, each object receives a retain message before its id is added to the array. When an object is removed from an array, it’s sent a release message.

It says each element is sent a retain message when added, and **is sent a release message when REMOVED from the array***.


The explanation of retain and release applies to the *elements* of the NSArray, not the NSArray itself. This is not covered by the general rules in the introductory docs, so it makes sense to mention it here. Sorry if someone mentioned this already.

--Andy

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Trying to understand -- please help... (From: Johnny Lundy <email@hidden>)

  • Prev by Date: Re: Trying to understand -- please help...
  • Next by Date: Re: Cocoa et al as HCI usability problem
  • Previous by thread: Re: Trying to understand -- please help...
  • Next by thread: connections and the nib lifecycle
  • Index(es):
    • Date
    • Thread