CPArray (CPPredicate): -filteredArrayUsingPredicate: and -filterUsingPredicate:

Use CPArray methods (not js array) because the receiver can be a CPArray subclass. With tests.

Fixes the bug reported here: https://groups.google.com/forum/?pli=1#!topic/objectivej/8q9hqbZZUv0
This commit is contained in:
cacaodev
2011-12-29 17:16:53 +01:00
parent 1ea95bf6e0
commit b39f509263
3 changed files with 27 additions and 2 deletions
+12
View File
@@ -547,6 +547,18 @@
[self assertTrue:[[arrayController arrangedObjects] count] > 0];
}
- (void)testArrangedObjectsWithPredicateFilteringAfterContentArrayBinding
{
_contentArray = [self makeTestArray];
var arrayController = [[CPArrayController alloc] init];
[arrayController bind:@"contentArray" toObject:self withKeyPath:@"_contentArray" options:nil];
[arrayController setFilterPredicate:[CPPredicate predicateWithFormat:@"department.name BEGINSWITH 'Capp'"]];
var arrangedCount = [[arrayController arrangedObjects] count];
[self assertTrue:(arrangedCount == 2) message:@"Count should be 2 and is " + arrangedCount];
}
/**
In a table with arranged contents like [1, 1, 2, 1], selecting the second '1' and removing it
should result in [1, 2, 1] - not [2]. E.g. we don't use removeObject:1 but only remove the