sbenitezb
sbenitezb

Reputation: 535

How do I preselect an item in NSPopUpButton bound to core data?

I have an NSPopUpButton with bindings to core data. I need to preselect an item in the list dynamically when the view is loaded. Is there a way to get a notification when the NSArrayController is ready? Or any other way to do it?

Upvotes: 0

Views: 164

Answers (2)

Willeke
Willeke

Reputation: 15589

Bind the selected object of the popup button to a property of the VC. Make sure the property is set before the popup button is drawn.

Upvotes: 1

DDP
DDP

Reputation: 2563

Try adjusting your selection using GCD with

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: {
  // Set selection.
}

You could call this from the array or view / window controller's awakeFromNib for example.

Upvotes: 0

Related Questions