ios - 自动删除领域对象
问题描述
我正在试验一个示例领域代码,并添加了一个选项来根据某个值自动删除特定对象。但是我需要做的是重新加载 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];
}
}
}
解决方案
推荐阅读
- excel - Excel:添加多个 h:mm:ss 单元格
- c++ - C++ 将地址保存为字符串的向量转换为新向量
- macos - 在使用“包”制作 .pkg 文件时编写 shell 脚本
- javascript - 正确的语义使模态叠加在单击 div 时消失
- java - 如何传递一个字符串参数,使其成为类方法调用的一部分?
- php - PHP:在不实例化类的情况下获取所有类属性(公共和私有)的列表
- eclipse - “税收无法解析为变量”
- r - 使用 data.tables 链接多个 data.table::merge 操作
- python - 如何使在一个终端中运行的程序的输出成为另一个终端的输入?
- javascript - 基于单选按钮显示/隐藏表单字段