• 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: NSImage allocation issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage allocation issues


  • Subject: Re: NSImage allocation issues
  • From: Nicko van Someren <email@hidden>
  • Date: Fri, 30 Apr 2004 15:03:15 +0100

On 30 Apr 2004, at 13:16, Clark Cox wrote:

On Apr 30, 2004, at 07:41, Jesus De Meyer wrote:
...
This is what I currently do:

NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:theItem action:nil
keyEquivalent:@""];
NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:itemPath];

if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"showIcons"]
intValue] && icon) {
[icon setSize:NSMakeSize(16, 16)];
[mi setImage:icon];
}
[menu addItem:mi];

Anybody know how I can fix this?

I don't see the problem. The image is retained by the menu item.

I think that the menu item is over-retained. It is created using alloc and retained by the menu. I suspect tacking [mi release] after the menu item is added to the menu might fix this.

Nicko
_______________________________________________
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: 
 >NSImage allocation issues (From: Jesus De Meyer <email@hidden>)
 >Re: NSImage allocation issues (From: Clark Cox <email@hidden>)

  • Prev by Date: Getting updated insertion point from NSDraggingInfo
  • Next by Date: Icons in popups with controller layer
  • Previous by thread: Re: NSImage allocation issues
  • Next by thread: Re: NSImage allocation issues
  • Index(es):
    • Date
    • Thread