Re: Convience Methods and Collections
Re: Convience Methods and Collections
- Subject: Re: Convience Methods and Collections
- From: James Bucanek <email@hidden>
- Date: Fri, 30 Mar 2007 12:29:05 -0700
Ryan Marsh wrote on Friday, March 30, 2007:
>Yes rootNode is a dictionary. Thanks for your help, it must be that
>something else is wrong. I'll look in to NSZombie and ObjectAlloc.
While we're on the subject, another trick I often use is a "sacrificial object". I'll create a subclass of NSObject that overrides retain, autorelease, and release. (Or, I'll override these in an existing class I'm having problems with.) Something like this:
- (id)retain
{
return ([super retain]);
}
- (void)release
{
[super release];
}
...
I then throw an autoreleased instance of this object into a collection.
The only purpose here is that I can now set a breakpoint at release and use the debugger to see when and where the object is getting released. This is sometimes faster than trying to plow through an ObjectAlloc graph.
>The only difference between it working and not working is when I use
>initWith... vs. arrayWith. My gut tells me (having limited knowledge
>of Objective-C) that using the alloc and initWith would be an over-
>retain when adding to a collection. But faced with the results of
>this test I was confused... and still am.
Your gut is correct. Unless you later release or autorelease an object created with alloc+init, it will be overretained.
>Like you said, it must be something else.
Good luck,
James
--
James Bucanek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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