Xcode 7: Binding an array controller to a radio button group

前端 未结 1 805
孤独总比滥情好
孤独总比滥情好 2021-01-26 03:06

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

相关标签:
1条回答
  • 2021-01-26 04:07

    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.

    0 讨论(0)
提交回复
热议问题