首页 > 解决方案 > 自动删除领域对象

问题描述

我正在试验一个示例领域代码,并添加了一个选项来根据某个值自动删除特定对象。但是我需要做的是重新加载 tableview 但是当我添加 [baseTableView reloadData]; 应用程序崩溃,异常“对象已被删除或无效”。有谁知道我该如何解决这个问题,以便表格视图更新并删除自动删除的行。我的删除代码是:

-(IBAction)delline:(id)sender
{




NSInteger count = [QueueArray count];
for (NSInteger index = (count - 1); index >= 0; index--) {
    person = QueueArray[index];
    if ([person.emailaddress1 isEqualToString:@"test"]) {

          NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
            [dbManager deleteRealmObject:[QueueArray objectAtIndex:index]];
            NSLog(@"DELETE PATH: %ld", (long)index);
            // set to whatever you want to be selected first
            [baseTableView selectRowAtIndexPath:indexPath animated:NO  scrollPosition:UITableViewScrollPositionNone];

            UITableViewCell *cell = [baseTableView cellForRowAtIndexPath:indexPath];

            cell.userInteractionEnabled = NO;
            cell.textLabel.text = @"UPLOADED SUCCESSFULLY";
            cell.detailTextLabel.text = @"";
        [baseTableView reloadData];

    }

}


}

标签: iosobjective-cxcoderealm

解决方案


推荐阅读