NSTableview datasource and NSPopupButtonCell

Discussion in 'Mac Programming' started by mongrol, Jul 24, 2008.

  1. mongrol macrumors regular

    Jul 16, 2007
    For some reason none of my posts to the cocoa-dev list are getting through so here's question for the forum. :)

    I have a NSTableview with a datasource consisting of an NSArray of
    dictionaries. One column in my table has an NSPopupbuttonCell. The
    content and contentValues are bound to a Core Data "Account" object.
    I use a "name" property as my contentValue.

    I'm having trouble changing the popup button. I know in my datasource
    I get an index of the selected object and in my setObjectValue
    datasource method I set the key in the dictionary with this new
    NSNumber intValue. However, in operation when I change the popupbutton
    it very quickly changes back to the first object in the list (index

    Clearly I'm missing something or have set something wrongly in IB.
  2. Mike Greiner macrumors newbie

    Nov 29, 2008

    I was having the same problem and I found your post in a search. Eventually I figured out what the issue was.

    Most likely, you have your bindings set incorrectly. Don't bind the Content of the NSTableColumn, but rather bind its Content Values to your "Account" collection (model key should be "account.name"). Then bind Selected Value to "XXX.account", (the account relationship of whatever entity you're editing).

    Hope that helps.


Share This Page