Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving Problems With UISearchBar in UITableViewController
    primarykey
    data
    text
    <p>I am trying to add a UISearchBar to my UITableView.</p> <p>This is the method they use to search:</p> <pre><code>- (void) searchTableView { NSString *searchText = searchBar.text; NSMutableArray *searchArray = [[NSMutableArray alloc] init]; for (NSDictionary *dictionary in listOfItems) { NSArray *array = [dictionary objectForKey:@"Countries"]; [searchArray addObjectsFromArray:array]; } for (NSString *sTemp in searchArray) { NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch]; if (titleResultsRange.length &amp;gt; 0) [copyListOfItems addObject:sTemp]; } [searchArray release]; searchArray = nil; } </code></pre> <p>But I don't have a dictionary, I just want to search in my array 'exerciseArray' which is init like this:</p> <pre><code>NSString *path = [[NSBundle mainBundle]pathForResource:@"data" ofType:@"plist"]; NSMutableArray *rootLevel = [[NSMutableArray alloc]initWithContentsOfFile:path]; self.exerciseArray = rootLevel; [rootLevel release]; </code></pre> <p>When I NSLog it, I get:</p> <pre><code>exerciseArray: ( { exerciseName = "Balance Board"; }, { exerciseName = "Barbell Seated Calf Raise"; }, { exerciseName = "Calf Press On The Leg Press Machine"; }, { exerciseName = "Calf Raises- With Bands"; }, </code></pre> <p>So can anyone help me modify the search method to fit the array I have? It seems to have a key in it.</p> <p>I tried this but it did not work and crashed at line <code>NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];</code> </p> <p>with error <code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary rangeOfString:options:]: unrecognized selector sent to instance 0x2d6450</code></p> <pre><code>- (void) searchTableView { NSString *searchText = searchBar.text; NSLog(@"exerciseArray: %@", exerciseArray); for (NSString *sTemp in listOfItems) { if (sTemp) { NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch]; if (titleResultsRange.length &gt; 0) [copyListOfItems addObject:sTemp]; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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