• 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: Weird problem with documents SOLVED
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird problem with documents SOLVED


  • Subject: Re: Weird problem with documents SOLVED
  • From: James DiPalma <email@hidden>
  • Date: Sun, 14 Jul 2002 12:36:41 -0400

That would be a bug in AppKit that illustrates what someone hopefully said about singletons during our singleton discussion a few days ago: if you return a shared instance from an init method, you must retain it before returning it.


Somehow, I got an NSFontManager object in my document. That's probably a bad, bad thing.

Only because init does not retain:

manager = [NSFontManager sharedFontManager];
NSLog(@"[NSFontManager sharedFontManager] 0x%x retain %d", manager, [manager retainCount]);
manager = [[NSFontManager alloc] init];
NSLog(@"[[NSFontManager alloc] init] 0x%x retain %d", manager, [manager retainCount]);

2002-07-14 12:27:11.795 Font[3357] [NSFontManager sharedFontManager] 0x163d10 retain 1
2002-07-14 12:27:11.795 Font[3357] [[NSFontManager alloc] init] 0x163d10 retain 1

On Sunday, July 14, 2002, at 11:54 AM, Donald Brown wrote:
Found the solution--I'd created a contextual menu for an NSTextView, and
dragged the Fonts Menu into it. This pulled along the NSFontManager, and
thus things went downhill from there. Deleting the Fonts menu from the
popupmenu let me delete the NSFontManger, fixing that problem. So, if
you're going to have font options in a popup menu in a nib other than the
main nib, you'll have to roll your own.

Donald

on 7/14/02 10:10 AM, James DiPalma at email@hidden wrote:

Guessing here: Do you have a top level object in your nib that returns a
shared instance from its init method?

Yes.


-jim
_______________________________________________
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: 
 >Re: Weird problem with documents SOLVED (From: Donald Brown <email@hidden>)

  • Prev by Date: Re: Weird problem with documents
  • Next by Date: NSTableView header cell size
  • Previous by thread: Re: Weird problem with documents SOLVED
  • Next by thread: Re: Weird problem with documents
  • Index(es):
    • Date
    • Thread