Hi all, I have an interesting one today...
I have a NSMutableArray, which is managed by an NSArrayController. I insert objects into the array using the insertObject:atArrangedObjectIndex: method of NSArrayController. I then display this data in an NSTableView.
This all works just fine, I can insert objects and delete them, and the table view is automatically updated. However, when the table view is sorted on one of the columns (via clicking on a column heading), any object added via the insertObject:atArrangedObjectIndex: method is put at the end of the mutable array. For example if I try to insert a new object at index 0 when the array contain six objects, the new object will be inserted into the array at index 6.
This only happens when the table is sorted, otherwise the behaviour is fine. Somewhere the index specified gets changed to the size of the array.
If anyone can shed any light on this issue I would very much appreciate it as once I've fixed this my app will be useable.
I have a NSMutableArray, which is managed by an NSArrayController. I insert objects into the array using the insertObject:atArrangedObjectIndex: method of NSArrayController. I then display this data in an NSTableView.
This all works just fine, I can insert objects and delete them, and the table view is automatically updated. However, when the table view is sorted on one of the columns (via clicking on a column heading), any object added via the insertObject:atArrangedObjectIndex: method is put at the end of the mutable array. For example if I try to insert a new object at index 0 when the array contain six objects, the new object will be inserted into the array at index 6.
This only happens when the table is sorted, otherwise the behaviour is fine. Somewhere the index specified gets changed to the size of the array.
If anyone can shed any light on this issue I would very much appreciate it as once I've fixed this my app will be useable.