Array controller inserts object in wrong arranged object position if there are no sort descriptors defined
This commit is contained in:
Klaas Pieter Annema
2010-07-20 14:59:18 +02:00
parent 2a4d3507b8
commit c17a3533ec
+10 -3
View File
@@ -400,16 +400,23 @@
if (_filterPredicate === nil || [_filterPredicate evaluateWithObject:object])
{
var pos = [_arrangedObjects insertObject:object inArraySortedByDescriptors:_sortDescriptors];
var position;
if ([_sortDescriptors count] > 0)
position = [_arrangedObjects insertObject:object inArraySortedByDescriptors:_sortDescriptors];
else
{
[_arrangedObjects addObject:object];
position = [_arrangedObjects count] - 1;
}
if (_selectsInsertedObjects)
{
[self setSelectionIndex:pos];
[self setSelectionIndex:position];
}
else
{
[self willChangeValueForKey:@"selectionIndexes"];
[_selectionIndexes shiftIndexesStartingAtIndex:pos by:1];
[_selectionIndexes shiftIndexesStartingAtIndex:position by:1];
[self didChangeValueForKey:@"selectionIndexes"];
}
}