jfewtr
jfewtr

Reputation: 155

NSButton argument binding in view-based NSTableView

View-based NSTableView with a single column. Each 'cell' contains several NSTextFields, an NSImageView and an NSButton, all of which are bound to various attributes of the objectValue of the Table Cell View. The NSTableView's content is bound to the arrangedObjects of an NSArrayController, which is in Entity mode and bound to the relevant NSManagedObjectContext.

The NSTextFields and NSImageView behave as expected. For some reason, however, the NSButton does not. It is always disabled. I have bound its argument to a property of the objectValue and its target to the File's Owner. Experimentation indicates that it is the argument binding rather than the target binding that is causing the trouble. The impression is that the argument value must be nil, so causing the button to be disabled. And yet it really cannot be, because the other bindings (NSTextFields, etc) work fine.

I have used button argument/target bindings many times in cell-based table views without problems. So I thought perhaps there was some characteristic of view-based table views that meant such bindings do not work. But Apple's TableViewPlayground sample uses this approach (in the HUD panel) without issue. My bindings are set up in exactly the same way. The only difference I can see is that Apple's example uses a class-mode array controller whereas mine is entity-mode. But I can't believe that that is the problem (or at least I very much hope it isn't as that would be a severe weakness).,

Upvotes: 2

Views: 1291

Answers (1)

Cameron Hotchkies
Cameron Hotchkies

Reputation: 1509

I spent a few hours on this exact same problem. In my case, the NSTableView's delegate was not set to the File's Owner as well. Once setting that, everything started to function properly.

Upvotes: 7

Related Questions