When I pre-added a button to the NSCollectionViewItem's view, I can bind its action in the inspector:
Which works without problem.
Now I'd like to create that button programmatically within the view's mouseDown:
, what should I assign to the bind:
option for the same result as the "Bind to: Collection View Item" in inspector?
Here's the code: (Swift)
aButton!.bind(
"argument",
toObject: ???, // <- what should I set here?
withKeyPath: "representedObject",
options: options
)
EDIT: I was able to do it by subclassing NSCollectionView then override newItemForRepresentedObject:
to assign the representedObject to the subclass view.
Still like to know if there are ways without subclassing NSCollectionView.