Re: Releasing what's in an array?
Re: Releasing what's in an array?
- Subject: Re: Releasing what's in an array?
- From: Shawn Erickson <email@hidden>
- Date: Fri, 25 Feb 2005 10:38:22 -0800
On Feb 25, 2005, at 10:23 AM, Mark Dawson wrote:
removing an object out of an array causes a release to happen (if there isn't a prior retain causing that object to be retained)
To insure clarity the above isn't true as worded (I think I know what you meant but)...
Arrays retain things when added and release them when removed (when an array is deallocated it implicitly removes all contained objects), it doesn't matter who or whatever else may have or may not have retained the object in question.
Make sure to understand that "release" does NOT imply an object will go away (aka be deallocated) it only means that the retain count has been reduced by one. If the retain count reaches zero, i.e. no one is retaining it any longer, then it will be deallocated by being sent a dealloc message.
In other words...
removing an object out of an array causes a release to be sent to it and the object possibly deallocated if there isn't at least a prior retain (implicit or otherwise) causing that object to have a non-zero retain count
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden