TableView UISearchBar on Tab Bar Controller Crashing Search

Discussion in 'iOS Programming' started by bradnet, Jun 14, 2010.

  1. bradnet macrumors newbie

    Mar 8, 2010
    Hi guys

    Please be gentle i'm a noob at this and i've been playing around with a search facility for my application table view for a while now trying to get it working but i keep getting the same error in my console.

    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary rangeOfString:eek:ptions:]: unrecognized selector sent to instance

    I believe that this following section may be the problem but i'm still not sure i've tried passing some NSlog entries inside the if statement and it seems to get through it but the problem is when i click on the search bar and starting typing, the first letter i type calls the error and cancels my app.

    Here is where i think the problem is
    - (void) searchTableView {
    //---clears the search result---
    [searchResult removeAllObjects];

    for (NSString *description in dataArray)
    NSRange titleResultsRange =
    [description rangeOfString:searchBar.text options:NSCaseInsensitiveSearch];
    if (titleResultsRange.length > 0)
    [searchResult addObject:description];

    I am searching an array of dictionaries each dictionary contains two objects one called text which is a string and the other is called checked which is a bool to determine the current state of the item.


    Here is a copy of the textdidchange section as the problem may also be located here but again i'm not sure.
    - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {

    [searchResult removeAllObjects];

    //---if there is something to search for---
    if ([searchText length] > 0) {
    isSearchOn = YES;
    canSelectRow = YES;
    self.tableView.scrollEnabled = YES;
    [self searchTableView];
    else {
    //---nothing to search---
    isSearchOn = NO;
    canSelectRow = NO;
    self.tableView.scrollEnabled = NO;
    [self.tableView reloadData];

    Any help would be much appreciated.


Share This Page