On Dec 24, 2009, at 2:23 AM, John Engelhart wrote:

> On Wed, Dec 23, 2009 at 12:05 PM, Bill Bumgarner <b...@mac.com> wrote:
> 
>> On Dec 22, 2009, at 11:49 PM, Franck Zoccolo wrote:
>> 
>>> You said that you're using garbage collection. When using GC retain and
>>> release messages do nothing, and the retain count is not used to
>>> determine when an objet can be freed from memory.
>> 
>> If -retainCount is returning 1, then he can't be using GC.   Under GC,
>> -retainCount -- being the utterly useless method that it is that no one
>> should ever call -- returns self.
>> 
>> b.bum
> 
> 
> Wait, what?  I could understand that under GC -retain might be nothing more
> than the equivalent of "- (id)retain { return(self); }", but -retainCount?
> Is it really "- (NSUInteger)retainCount { return((NSUInteger)self); }" ?
> Wouldn't it make more sense to just return 1, or maybe something like
> NSUIntegerMax?

There is no implementation of -retainCount under GC.  There's a short-circuit 
in obj_msgSend that detects the selector for the memory management methods 
which are no-ops.  Since -retain and -autorelease have to return self, that's 
what the short-circuit does.  -retainCount gets the same treatment and so the 
same return value.  The return value doesn't matter, anyway.  (Frankly, it 
hardly matters under managed memory, either.)

Regards,
Ken

_______________________________________________

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 arch...@mail-archive.com

Reply via email to