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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to