开发者

Possible to limit results returned by NSArray filteredArrayUsingPredicate

开发者 https://www.devze.com 2023-01-15 20:30 出处:网络
I\'m using [NSArray filteredArrayUsingPredicate] to get an array ofobjects that match certain conditions within an original array of 20,000 objects.Is it possible to limit th开发者_JS百科e number of r

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 th开发者_JS百科e number of results that this method returns in order to speed it up?

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


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消