Ishi
Ishi

Reputation: 3

Bindings in NSPopUpButtonCell

I have the following class:

@interface QFormatRowData : NSObject
@property (copy) NSString *rowText;
@property (copy) NSString *completeAssetName;
@end

In the bindings inspector of NSTableColumn (inside an outline view and it contains a NSPopUpButtonCell), I binded Content to a array controller called FormatAs (which contains objects of class QFormatRowData) with controller key = arrangedObjects and model key path = rowText.

Then I binded Content values to the same "FormatAs" array controller with controller key = arrangedObjects and model key path = completeAssetName.

Then I binded Selected Object to a tree controller called "dstAssetTreeController" with Controller key = arrangedObjects and model key path = formatAssetName (which is a member in the treecontroller's class).

Now I want that the pop up button cell shows options as rowText but when selected, the value of completeAssetName is allocated to formatAssetName.

That is not happening with my bindings. How to fix this?

Upvotes: 0

Views: 69

Answers (1)

Willeke
Willeke

Reputation: 15623

  • Bind Content to arrangedObjects, no model key path.
  • Bind Content Objects (returned by selectedObject or selectedObjects in place of the corresponding content object) to arrangedObjects, model key path completeAssetName.
  • Bind Content Values (displayed as the items in the NSPopUpButtonCell) to arrangedObjects, model key path rowText.
  • Bind Selected Object to tree controller dstAssetTreeController, arrangedObjects, model key path formatAssetName.

Documentation: NSPopUpButtonCell Bindings

Edit:

Xcode crashes when binding Content Objects. Workarounds:

  • The cell-based NSTableView and NSOutlineView are deprecated. Convert to view-based.
  • Keep trying until Xcode doesn't crash.
  • Use Accessibility Inspector to confirm the Model Key Path text field.

Upvotes: 0

Related Questions