我正在使用UITableView多重选择和sqlite3。 通过下面的代码,我可以显示多个选择,但是对数据库的保存机制有问题。UITableView多重选择
updatedID是一个NSInteger。
当调试消息是如下面,就在--->self.updatedID = ct.contactID;
程序接收到的信号:“EXC_BAD_ACCESS”。
我的代码在这里出了什么问题?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *theCell = [tableView cellForRowAtIndexPath:indexPath];
MyContacts *ct = (MyContacts *) [self.memberNoGroupArray objectAtIndex:indexPath.row];
self.updatedID = ct.contactID;
if (theCell.accessoryType == UITableViewCellAccessoryCheckmark)
{
DBAccess *updateDB = [[DBAccess alloc] init];
[updateDB updateGroupName:updatedID withGroupName:[NSString stringWithFormat:@"(no group)"]];
[updateDB release];
theCell.accessoryType = UITableViewCellAccessoryNone;
}
//if the cell doesn't have checkmark, give it a checkmark.
else if (theCell.accessoryType == UITableViewCellAccessoryNone)
{
DBAccess *updateDB = [[DBAccess alloc] init];
[updateDB updateGroupName:updatedID withGroupName:self.currentGroupString];
[updateDB release];
theCell.accessoryType = UITableViewCellAccessoryCheckmark;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
非常感谢!