Re: menu madness with retain count
Re: menu madness with retain count
- Subject: Re: menu madness with retain count
- From: vincent habchi <email@hidden>
- Date: Tue, 27 Apr 2010 20:58:10 +0200
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 (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