Я работаю с несколькими вариантами UITableView и sqlite3.
С помощью этого кода ниже я могу отображать несколько вариантов выбора, однако механизм сохранения в БД имеет проблемы.
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];
}
Большое спасибо!