Le 27 avr. 2010 à 20:42, Jens Alfke a écrit :

> What you "own" are references. If you call a method that creates a reference, 
> like +alloc, -retain or -copy, then you now own a reference to that object. 
> For as long as you own that reference, the object will stay around. When you 
> don't need the object anymore, you have to release that reference by telling 
> the object to -release or -autorelease.
> 
> [And +1 on ignoring -retainCount. The only time this method is useful is if 
> you are in gdb debugging some kind of tricky refcounting error; and even then 
> you have to take its value with a grain of salt due to the effect of the 
> autorelease pool.]

Yet, at the same time, you may want the dealloc: method to trigger some events. 
For example, if you have a CALayer that holds various sublayers, and that 
CALayer goes away, you may want all the sublayers to go away at the same time. 
Yet, this is impossible if some other object around locks a reference to the 
sublayers.

By the way, how are exactly multiple calls to [object autorelease] handled by 
the pool? Does this give rise to as many calls to release: as they are 
autorelease references stored, or does the pool directly adjust the retain 
count?

Vincent_______________________________________________

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