4

I am using view based NSTableViews that is populated using bindings and array controllers with core data. Everything works great--cells with text and buttons and cells with image and text--I can edit the text as well, etc.

What I can't figure out and have searched everywhere is how to populate the popup menu. There are 2 array controllers, one for table view and one for popup buttons menu items.

I have tried binding the popup menu the classic way: by binding content (arrangedObjects to entity Place), content values (arrangedObjects Place.name), and selected object (Table Cell View objectValue.places.name.

Shouldn't all the controls should work like normal controls in view based tableviews? The menu is not getting populated. However, if the tableView's entity already has a value/relation set the value is being shown correctly.

Any help would be super. Thanks, Dan

pahladan
  • 41
  • 1
  • 3

2 Answers2

5

I think there is a bug here, I faced exactly the same problem. Here's my work-around:

Instead of binding the pop-up button directly to the Array Controller in IB, I put an outlet (named arrayController) in my nib's File's Owner to the NSArrayController and bound the pop-up button like this:

settings

Alexander
  • 23,432
  • 11
  • 63
  • 73
Mickaël
  • 310
  • 3
  • 8
  • 1
    Confirmed. This fixed same problem for me. – Byron Jul 24 '12 at 05:31
  • It does not work for me. I must be doing something wrong. I have a view based table, an outlet, and tried bindings on both button and button cell. Is there anything obvious I am forgetting? – Carelinkz Dec 21 '12 at 23:14
  • I'm having exactly the same problem on 10.8 (XCode 4.6). The workaround doesn't work for me either. Did anyone ever file a radar on this? – Lukas Feb 05 '13 at 09:35
  • I put a demo app here: https://github.com/zehrer/NSPopUpButtonDemo which use this workaround. But is this really a bug? – Stephan Aug 10 '13 at 11:33
  • 1
    It seems Lukas wrote a fruther detailed problem description here: http://stackoverflow.com/questions/14708947/nspopupbutton-in-view-based-nstableview-getting-bindings-to-work – Stephan Aug 11 '13 at 08:01
  • @Mickaël solution doesn't work for me neither in **NSTableView in View Based mode**, though it works great in Cell Mode and in NSCollectionView. – Benoît Lahoz Nov 12 '13 at 19:24
  • To make this workaround work I additionally had to set the table view's delegate outlet. – Sbhklr Dec 04 '13 at 14:51
1

check this out:

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaBindings/Tasks/onerelation.html

http://www.tbef.se/blog/2006/08/31/core-data-bindings-nstableview-and-nspopupbuttoncell/

CHECK that only 3 params were set!!

Content
Bind to: LanguagesArrayController
Controller Key: arrangedObjects
Model Key Path:

Content Values
Bind to: LangsArrayController
Controller Key: arrangedObjects
Model Key Path: name

Selected object
Bind to: CoursesArrayController
Controller Key: arrangedObjects
Model Key Path: language