My setup:
I'm making a tab-based application using an NSTableView to display tabs and allow users to select tabs.
I have an NSTableView bound to an NSArrayController (tableView.content is bound to arrayController.arrangedObjects, tableView.selectionIndexes is bound to arrayController.selectionIndexes).
My arrayController content is bound to an NSMutableArray in my ViewController.
My arrayController is NOT set to select inserted objects (see screenshot)
My problem:
Whenever I call [myArrayController addObject:], the selectedIndex changes back to 0 (even though I have "Preserve Selection" checked). I don't want this behavior. I want the selection to remain on the same tab after adding or removing objects.
Has anyone run into this situation before?
selectedIndex
. The Selection Indexes property of NSArrayController is an NSIndexSet and not an NSUInteger. I can easily imagine how a mismatch like that could manifest in the problem you're seeing. – ipmcc