Re: Releasing what's in an array?
Re: Releasing what's in an array?
- Subject: Re: Releasing what's in an array?
- From: Andy Armstrong <email@hidden>
- Date: Fri, 25 Feb 2005 19:47:07 +0000
On 25 Feb 2005, at 19:35, Charlton Wilbur wrote:
If you have an object you did allocate, it's often wise to release it
after adding it to the array and then later retain it if you want to
remove it from the array - it's simpler to match an alloc/release
around adding it to the array and a retain/release around removing it
from the array than it is to match an alloc around adding it to the
array with a release around removing it from the array; in particular,
you know when you allocate or otherwise obtain the object whether you
need to release it, while you might not know that when you remove it
from the array.
(I know you're not suggesting otherwise Charlton - just clarifying)
If you do that though you must retain the object /before/ removing it
from the array otherwise you will end up trying to retain an object
that has already been deallocated.
--
Andy Armstrong, hexten.net
_______________________________________________
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