On Sep 12, 2013, at 1:41 PM, Graham Cox <graham....@bigpond.com> wrote:

> On 12/09/2013, at 6:57 PM, Bill Cheeseman <wjcheese...@gmail.com> wrote:
> 
> ....
> 
>> The point remains, however, that the getter that started this thread 
>> returned an object retained, and the caller therefore owns it and is 
>> responsible for releasing it. 
> 
> There's an inherent contradiction in this statement. If it's a getter, then 
> the caller has no responsibility for ownership of the returned object. If the 
> caller does have that responsibility, then it's not a getter. In fact, 
> -eventTypes in this case *is* a getter, or is intended to be.


The Advanced Memory Management Programming Guide I cited earlier says this 
about the Cocoa ownership rules, which I can't reconcile with your assertion 
that getters always leave the caller with no responsibility for ownership of 
the returned object.

"You can take ownership of an object using retain
"A received object is normally guaranteed to remain valid within the method it 
was received in, and that method may also safely return the object to its 
invoker. You use retain in two situations: (1) In the implementation of an 
accessor method or an init method, to take ownership of an object you want to 
store as a property value; and...."
I wonder if you are perhaps thinking of the Core Foundation Create Rule, which 
does say that a function named with "get" does not return a retained object (is 
returned by reference). If you can refer to any Cocoa documentation to the 
effect that getters never confer ownership in Cocoa, please pass it along.
-- 

Bill Cheeseman - b...@cheeseman.name

_______________________________________________

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

This email sent to arch...@mail-archive.com

Reply via email to