Search code examples
objective-ccocoabindingnsmutablearraynsarraycontroller

How to bind a NSMutableArray to NSArrayController's selection?


I have NSMutableArray (arr1), and NSArrayController for that arr1.

I'd like to have another NSMutableArray's content to be the selection of the NSArrayController.


Solution

  • You can observe the array controller's selectedObjects informal property using KVO, and apply the changes to your own array.

    There's no documented way to set that up any more automatically than that. I've had success setting up custom bindings without overriding the bind:::: method in views, but not in non-views, so I wouldn't consider that reliable.