如何修复filteredArrayUsingPredicate的非常慢的性能

时间:2015-10-16 11:06:54

标签: ios objective-c performance

for(NSInteger item = 0; item < items; item++){
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:section];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(SELF.indexPath, $a, $a == %@).@count != 0", indexPath];

    NSArray *row = [[reticleMatrix filteredArrayUsingPredicate:predicate] firstObject];

    MatrixElement *thisElement = nil;
    if(row){
        for(MatrixElement *element in row){
            if([element.indexPath isEqual:indexPath])
                thisElement = element;
        }
}

我有这段代码,但似乎放慢了我的滚动视图。我怎样才能解决这个问题? enter image description here

0 个答案:

没有答案