Reputation:
I cannot figure a way to enable/disable editing in view based NSTableViews using cocoa bindings. I mean, I can perfectly enable/disable editing in a separate NSTextField, by binding it's "editable" attribute to a file's owner property such as
@property BOOL canModify;
(bind to: file's owner) (Model Key Path: self.canModify)
But if I do exactly the same with a NSTextField in a view based TableView the binding seems to be totally ignored. Also to be noticed that I can populate the table via bindings/array controllers so it's quite strange that the stuff doesn't work only for the "editable" property. Thank you in advance
Upvotes: 2
Views: 1776
Reputation:
No. There's no problem in Apple's implementation of File's owner bindings for tablecellviews. I simply overlooked an IB warning. "... Objects inside view-based cells may only be connected to the tableview's delegate." I did set the "delegate" outlet of the TableView to my WindowController (implementing the "delegate protocol) and everything is working fine, without any double double double passages over table Cell's objectValues.
Upvotes: 2
Reputation: 90571
The name of your property and the key path of your binding don't match, although maybe that's just a typo: canModify
vs. canModyfy
("i" vs. "y").
The editable
binding should work just fine. You should check your other bindings, such as the value
binding, to see if it has the Conditionally Sets Editable binding option enabled. Annoyingly, this option is enabled by default.
Lastly, you haven't explained in which NIB you're defining your cell views. Are they defined in the same NIB as the table view itself, or are they in a separate NIB? That would affect which object is File's Owner.
Even when table cell views are defined inside the same NIB as the table view, I believe they are encoded as a NIB-within-a-NIB. That is, each table cell view subhierarchy is actually encoded into a NIB blob and that NIB blob is archived into the parent NIB. When the table cell view sub-NIB is loaded, the table view's delegate is usually supplied as its owner. So, binding to File's Owner may not have the effect you expect.
For table cell views, you usually bind the subviews (like an NSTextField
) to the table cell view itself, keyed off of the objectValue
property.
Upvotes: 0