This issue has been brought up a lot but I can't seem to optimize this piece of search code any further.
this filterSet array has about 1000 items and it's taking 8 seconds to reproduce results on a non-simulator iPad (simulator shows results in less than a second):
for(NSString *rowID in [self.filterSet array]) {
self.rowResults = [self.filteredResults filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"rowID = %@", rowID]];
self.rowResults = [self.rowResults valueForKey:@"value"];
self.duplicateValueSet = [NSOrderedSet orderedSetWithArray:self.rowResults];
filterCount = [[self.resultsArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF = %@", rowID]] count];
if([self.duplicateValueSet count] != filterCount)
filterCount -= abs([self.duplicateValueSet count] - filterCount);
if(filterCount == matchingCount)
[self.results addObject:rowID];
}
any suggestions to optimizing this query? The majority of the search is taken up in all the filters and predicate sorting. thanks.
edit: so i removed a lot of the code in the for loop and found the culprit to be the first line
self.rowResults = [self.filteredResults filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"rowID = %@", rowID]];
this is for some reason taking 7 seconds to execute. Is there a faster/more efficient way to create a predicate to match the rowID string? I've thought about using the makeobjectsperformselector NSArray method but for some reason I get the NSCFNumber unrecognized selector issue (which is saying my array has NSNumbers instead of NSStrings)