I have a small set of objects from which the user should be able to select one using a radio button group. The objects are already bound to an array controller. Is there a way t
You can bind the button state through objectValue
(NSTableViewCell
) in a view-based table, and representedObject
in a collection view (NSCollectionViewItem
).
If an NSArrayController
is configured to generate cells/items for those parent views, the views will maintain the state of the objectValue
and representedObject
binding targets for each view in the collection.
So in IB, you have one generic subview with a radio button in it, and you should be able to select "Collection View Item" with a keypath of representedObject.<whateverKeyPath>
for the binding of the radio button if it's within a collection view item. Or you could select "Table View Cell" with a keypath of objectValue.<whateverKeyPath>
if the button is a subview of a table view cell for a view-based table.
Though it may be dated by recent OSX 10.10 updates to NSCollectionView
, the quick start guide has good illustrations on how to configure bindings within subviews of collection views. Table view subview bindings are similar, though you use objectValue
rather than representedObject
as the property within the view.