0

Let's say I have a window with 2 combo boxes. The NSWindowController that control the window, has two mutable arrays that are bound to the combo boxes Content Values.

What I would like is that while the first combo box has fixed values, the second combo values depends on the first combo selected value.

What should I do to have the second combo box to reload its content when the associated mutable array updates (Or how should I update the array to make this happen?)?

Monolo
  • 18,205
  • 17
  • 69
  • 103
Pinco Pallino
  • 916
  • 1
  • 6
  • 18

1 Answers1

0

If you set the value of the second array through its normal accessor methods, the right update messages should be propagated to all bound values and other listeners.

// When first combo box changes value
// NSArray *newArray = // Fancy algorithm..
self.secondArray = newArray;

That should get the second combo box to update.

In case you do not want to change the instance of the NSMutableArray backing your property, you could use the mutable accessor methods, discussed here. They will let you change the contents of the mutable array without changing the array itself. And the KVC/KVO system will propagate the changes to the listeners.

Monolo
  • 18,205
  • 17
  • 69
  • 103