Search code examples
cocoacore-datainterface-buildernstableviewnsarraycontroller

NSButton inside tableCellView: how to use the "action invocation" for a View Based NSTableView/NSArrayController


For a View Based NSTableView/NSarrayController: how would I use the "action invocation" from a NSButton inside a tableCellView to change an attribute for an entity?

I have the following setup:

  • A "View Based" NSTableview with one column.
  • A NSarrayController which uses "entity mode" and is bound to core data entity.

Picture of the demo application

I would like to use the action invocation from the push button to update the entity. For example to set a "bool" attribute to true.

If I simply use the "model key path" and set it to objectValue.escaped the button is disabled.


Solution

  • To clarify my question:

    If I have another client for my data-source, connected for example via web-service and I want to trigger an event. I would use an entity-attribute to inform the client. Therefore I added a pushbutton to the tableCellView.

    I started with a NSTableView and a NSArrayController connected to a core-data entity as object controller. Text-Fields, images, check-boxes and popup-buttons worked immediately after they were bound to the control. But I found no workable solution to bind a "Push-Button".(I tried to subclass the control, the table, the cell-view and the button without success.)

    Finally I switched to the action/delegate method. With the methods rowForView:, itemAtRow: and representObject: it was possible to modify the attribute of the entity.

    I'm not happy with this inelegant solution (outlineView/detached code). If there IS a solution with the arrayControl please let me know.