• 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: NSMenu in NSTableView column
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMenu in NSTableView column


  • Subject: Re: NSMenu in NSTableView column
  • From: Keary Suska <email@hidden>
  • Date: Tue, 12 Aug 2014 08:34:28 -0600

On Aug 12, 2014, at 6:14 AM, Jonathan Taylor <email@hidden> wrote:

> I am trying to implement a popup menu in an NSTableView column. I seem to have the bindings all set up so that the values in my NSArray are updated according to the options the user selects in the table. However, I would like to have some way of accessing the tag on the menu item that was selected for each row. I thought I could wire up an outlet to the NSMenu object attached to the table column, but when I later attempt to access the relevant menu item in the menu (in order to look up its tag), I get the following runtime error:
>
>> -[NSMenu itemAtIndex:]: message sent to deallocated instance
>
> I do not encounter this error if I bind to a standalone popup menu, so I don't think I'm doing anything wildly stupid here. I can imagine that within the table the popup menu objects are being dynamically allocated, so the outlet plan isn't working out.

It's an "intuitive" mistake to made--I have made it a few times myself. It is not the case that there is a single menu for the column. In fact, there is a different NSPopupButtonCell for every row with (hopefully) a different NSMenu for each cell. If you construct it all in IB, this is what you get at run-time.

> My question then is how should I access the tags in the popup menu in order to work out which tag corresponds to the selected item in each row?

If I understand your setup correctly, the most direct route is to set an action on each menu item.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


  • Follow-Ups:
    • Re: NSMenu in NSTableView column
      • From: Jonathan Taylor <email@hidden>
References: 
 >NSMenu in NSTableView column (From: Jonathan Taylor <email@hidden>)

  • Prev by Date: Re: Mod (%) function in C/Objective-C?
  • Next by Date: Re: NSMenu in NSTableView column
  • Previous by thread: NSMenu in NSTableView column
  • Next by thread: Re: NSMenu in NSTableView column
  • Index(es):
    • Date
    • Thread