views:

35

answers:

1

I'm using [NSArray filteredArrayUsingPredicate] to get an array of objects that match certain conditions within an original array of 20,000 objects. Is it possible to limit the number of results that this method returns in order to speed it up?

This would be similar to the LIMIT clause in SQL. Thanks.

A: 

No, with predicates not. But you could make an extension to NSArray which filters and limits the result for you.

- (NSArray*)filteredArrayUsingPredicate:(NSPredicate*)predicate 
                            resultLimit:(NSUInteger)limit;
brutella