Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Although nobody answered my question, I figured it out myself.</p> <p>Actually, I thought too difficult. I wanted to use NSPredicate which wasn't necessary in my case. I wanted to have a string first from NSPredicate, and then compare the string. I now use rangeofstring, in a loop for every objectatindex, I do this for every array.</p> <p>If it's found in an array, report YES and the index will be put in a different array. This array will be used later on when making the UITableView, replacing the indexPath.row.</p> <pre><code>[self.searchResults removeAllObjects]; for (int i = 0; i &lt; [temp_category count]; i++) { BOOL foundResult = FALSE; if ([[temp_category objectAtIndex:i] rangeOfString:searchText].location != NSNotFound) { foundResult = TRUE; } if ([[price_producttitle objectAtIndex:i] rangeOfString:searchText].location != NSNotFound) { foundResult = TRUE; } if ([[price_type objectAtIndex:i] rangeOfString:searchText].location != NSNotFound) { foundResult = TRUE; } if ([[price_description objectAtIndex:i] rangeOfString:searchText].location != NSNotFound) { foundResult = TRUE; } if (foundResult) { NSNumber *result = [NSNumber numberWithInt:i]; if ([self searchResults] == nil) { NSMutableArray *array = [[NSMutableArray alloc] init]; [self setSearchResults:array]; [array release]; } [searchResults addObject:result]; } } NSLog (@"array = %i", [searchResults count]); NSLog(@"%@",searchResults); </code></pre> <p>I don't take credits for this answer. Credits should go to: <a href="https://stackoverflow.com/questions/8169889/searchdisplaycontroller-search-multiple-arrays">SearchDisplayController search multiple arrays</a></p> <p>I took this method and implemented it in a -(void)searchtableview. I should mention that there are not a lot of questions about this, and this was the only appropriate answer I could find.</p> <p>I hope others will find this useful as well!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload