NSArrayController remove: doesn't result in "selectionDidChange"
I have an array of objects, call them I1 objects. Each I1 object contains an array of I2 objects.
ArrayController1 controls objects of type I1, displayed in TableView T1.
ArrayController2 controls objects of type I2, displayed in TableView T2.
I use the selectionDidChange delegate method from from ArrayController1 to determine which objects are displayed in T2.
I add and remove I1 items using the add, (or add object) and remove calls to ArrayController1 from my model controller.
Every thing works 开发者_如何学编程fine, except when I remove an item from the middle of the T1 list, no selectionDidChange message is sent to my delegate, so the contents of the old (removed) I1 are still displayed in T2.
I suspect this has something to do with the fact that the "remove" is deferred until the next iteration of the runloop.
I don't see a clean way to get the selection change registered upon remove. I could, I suppose, look at selection indexes and reset the contents of T2 "by hand", so to speak.
Any suggestions will be appreciated.
Well, 5 views, my searching, no answers about how to do it automatically. (selectionDidChange message to the delegate is automatic when adding an object, but not when removing, apparently).
My solution is to set the selection index by hand when handling the remove action. set selection index does cause the delegate to be sent the didChange message.
精彩评论