• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Convience Methods and Collections
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Convience Methods and Collections (From: Ryan Marsh <email@hidden>)

  • Prev by Date: Subclassed NSArray, and using predicates and NSArrayController
  • Next by Date: Re: Core Data Memory issue on loading a saved file
  • Previous by thread: Re: Convience Methods and Collections
  • Next by thread: Re: Convience Methods and Collections
  • Index(es):
    • Date
    • Thread