Fix for #1723: CPArrayController insert

This fix addresses the following problems:

- fixes a bug with add: where it would try to add the sender object, not the represented object
- changes insert: to insert a new represented object after the currently selected object. If no object is currently selected it behaves like add: and adds a new object to the end.

This patch includes tests.
This commit is contained in:
Andrew Hankinson committed 2013-02-10 20:03:41 -05:00
1 parent 5f99ebefb1
commit ab49c63840
2 files changed
+49 -3

No files matched your search

+10 -3
View File
@@ -897,7 +897,9 @@
if (![self canAdd])
return;
[self insert:sender];
var newObject = [self automaticallyPreparesContent] ? [self newObject] : [self _defaultNewObject];
[self addObject:newObject];
}
/*!
@@ -909,9 +911,14 @@
if (![self canInsert])
return;
var newObject = [self automaticallyPreparesContent] ? [self newObject] : [self _defaultNewObject];
var newObject = [self automaticallyPreparesContent] ? [self newObject] : [self _defaultNewObject],
lastSelectedIndex = [_selectionIndexes lastIndex];
if (lastSelectedIndex)
[self insertObject:newObject atArrangedObjectIndex:lastSelectedIndex + 1];
else
[self addObject:newObject];
[self addObject:newObject];
}
/*!