• 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: Subclassing NSToolbar is *fully* really good
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing NSToolbar is *fully* really good


  • Subject: Re: Subclassing NSToolbar is *fully* really good
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Tue, 4 May 2004 14:44:18 -0700

Hello...

Well, just moving the delegate methods to a different class seems to fix everything, and it won't leak memory.

(In the toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: method below, you leak the copy of the NSToolbarItem)

Also, a general tip: when you are messing around with things like toolbars that save their state in the preferences, it's a good idea to either turn off the autosave if possible, or the delete the plist file for the preferences in between tests. That way you don't get messed up by any incorrect prefs that were created and saved by the previous version of your code.

Hope that helps,

Louis


PS: John, I'll email my modified version of your example project with just the delegate methods moved offlist, so you can check it out yourself...


Thank you Louis and Chris for your contributions. Whilst neither fixed the problem, they both put me on the right track. I figured that if it wanted a distinct copy of the NSToolbarItem, I would just use the (id)copy method to make a deep copy.

- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{
return [[toolbarItemDictionary objectForKey:itemIdentifier] copy];
}

Behold! Workage! Who would have thought that after buggerizing around for days, the answer would come in the form of a four letter word.
Thanks again for the help, guys. I wouldn't have thought to look where I did without your input.

Cheers,
john

P.S.
Louis wrote:
Delegate methods should be implemented in delegates :)

Meh! I hate having the same code doing the same thing in every window controlling subclass. It's just so... un-O-O. ;)
_______________________________________________
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: 
 >Subclassing NSToolbar is *almost* really good (From: John Lombardo <email@hidden>)
 >Re: Subclassing NSToolbar is *almost* really good (From: "Louis C. Sacha" <email@hidden>)
 >Re: Subclassing NSToolbar is *fully* really good (From: John Lombardo <email@hidden>)

  • Prev by Date: Re: NSTextField and bindings
  • Next by Date: Re: NSTextField and bindings
  • Previous by thread: Re: Subclassing NSToolbar is *fully* really good
  • Next by thread: [Q] Getting edited cell data before enter key pressed
  • Index(es):
    • Date
    • Thread