Ios UISearchBar-删除行

Ios UISearchBar-删除行,ios,uisearchbar,delete-row,Ios,Uisearchbar,Delete Row,我使用tableview和UISearchBar来搜索它。当我必须删除行时,我使用以下代码: - (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if(editingStyle == UITableViewCellEditingStyleDelete) {

我使用tableview和UISearchBar来搜索它。当我必须删除行时,我使用以下代码:

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath {

    if(editingStyle == UITableViewCellEditingStyleDelete) {

//Get the object to delete from the array.

    Coffee *coffeeObj = nil;

    if (tv == self.searchDisplayController.searchResultsTableView)
    {
        coffeeObj = [appDelegate.coffeeArrayFiltered objectAtIndex:indexPath.row];
    }
    else
    {
        coffeeObj = [appDelegate.coffeeArray objectAtIndex:indexPath.row];
    }


    appDelegate.countRowNumber -= 1;
    NSString *txtmessage2an = [NSString stringWithFormat:@"%@", coffeeObj.price];
    float priceFn = [txtmessage2an floatValue];
    NSString *txtmessage3a = [NSString stringWithFormat:@"%0.2f", priceFn];
    float stringDouble1 = [txtmessage3a floatValue];
    float stringDouble2 = appDelegate.countPriceNumber;
    float stringDoubleSum = stringDouble2 - stringDouble1;
    appDelegate.countPriceNumber = stringDoubleSum;
    [appDelegate removeCoffee:coffeeObj];

    //Delete the object from the table.

            [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            [self.tableView reloadData];

    if([appDelegate.searchTerm isEqualToString:@"!"]){
        NSLog(@"Not in search...");
    }
    else
    {
        NSLog(appDelegate.searchTerm);
        [self.searchDisplayController.searchBar setText:appDelegate.searchTerm];
    }
}
}
基本上它可以工作,但是当[self.searchDisplayController.searchBar setText:appDelegate.searchTerm];调用,则我得到以下错误:

2012-01-05 15:36:05.769 iTaxFriend[9261:707]-[NSIndexPath getCharacters:range::发送到实例0x3ab490的无法识别的选择器 2012-01-05 15:36:05.771 iTaxFriend[9261:707]***终止应用程序到期 未捕获异常“NSInvalidArgumentException”,原因: '-[NSIndexPath getCharacters:range:::]:无法识别的选择器发送到 实例0x3ab490'

我调用[self.searchDisplayController.searchBar setText:appDelegate.searchTerm];以刷新UISearch结果。当我在搜索栏上重新输入这一行并手工操作时,它不会崩溃


你知道如何刷新结果吗?

我正在编辑你的问题,以便从标题中删除Xcode标记和单词,因为你的问题与iOS有关,与Xcode IDE无关。