• 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: Unidentified Nib'ed Instance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unidentified Nib'ed Instance


  • Subject: Re: Unidentified Nib'ed Instance
  • From: Glenn Andreas <email@hidden>
  • Date: Sat, 27 Mar 2004 09:11:56 -0600

At 10:26 PM -0800 3/26/04, Seth Willits wrote:
In my NSDocument subclass (MyDocument) I have a reference to a custom class that wraps all of the data of the document (MyData). In the init method of MyDocument I create and initialize MyData by:

mMyData = [[MyData alloc] init];
[mMyData retain];

You're over-retaining it here - since you created the instantance with alloc/init, it is already retained (or, alternately, it hasn't been auto-released).

(BTW if someone can refresh me how to make init a class method that allocs and does all of the typical stuff I would want it to, I'd appreciate it, but if it's more than five lines I wouldn't bother - I'll look around and find it.)

@implementation MyData
+ (MyData *) myData
{
return [[[self alloc] init] autorelease];
}
@end

(OK, 6 lines, and since the factory method returns an auto-released object, you want to retain it)


--
Glenn Andreas email@hidden mondo blobbo, Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Unidentified Nib'ed Instance (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Where do I find the C headers?
  • Next by Date: Re: [ANN] Shovel - Third-Party "Software Update"
  • Previous by thread: Unidentified Nib'ed Instance
  • Next by thread: NSWindow Frame (auto) save
  • Index(es):
    • Date
    • Thread