Re: container retain/release problem
Re: container retain/release problem
- Subject: Re: container retain/release problem
- From: email@hidden
- Date: Thu, 10 Feb 2005 14:36:13 -0800
On Feb 10, 2005, at 2:25 PM, Paul Forgey wrote:
I've got an NSDictionary which I've built as per the quoted code
below.
dict will autorelease, however I've got an NSArray element in there
which I've retained. So therefore, it should stick around, shouldn't
it? Problem is after the autorelease pool gets run, my instance
variable 'updates' has either been released or completely trashed.
Copying the array doesn't make things act any differently. What
exactly am I doing wrong?
If you have -retain'd the array that is contained within the dictionary
then, yes, that array will continue to exist after the dictionary has
been deallocated (-release'd completely -- never invoke -dealloc
directly). If it isn't, then you are either over -release'ing it or
you never -retain'd it in the first place.
More likely than not this ...
![updates isKindOfClass:[NSMutableArray
class]]
... is not doing what you expected it to do. There isn't a way to test
an array for mutability; you have to know that it is mutable based
upon your usage patterns (or call -mutableCopy to guarantee
mutability). Try testing to see if it is of kind NSArray.
b.bum
_______________________________________________
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