UITableView multiple selections
I am working with UITableView multiple selections and sqlite3. With this code below I am able to display the multiple selections, however the saving mechanism to DB has problem.
updatedID is an NSInteger.
When debug, message is as below, right on the ---> self.updatedID = ct.contactID;
Program received signal: “EXC_BAD_ACCESS”.
What is wrong with my code here?
- (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];
}
Many thanks!
Use NSZombiesEnabled to find the cause of problem, and see them in debugger.
Go to XCode -> Projects -> Edit Active Executable "YourProjectName" -> Arguments tab -> go to ' Variables to be set in environment' -> add variable "NSZombiesEnabled" and put its value to "YES" and also don't forget to check the checkmark.
Then debug the code and see in debugger at the time of crash what is the cause of this error.
i got this message in the debugger :
GDB:Program received signal: "SIGABRT".
and sometimes this:
GDB:Program received signal: "EXC_BAD_ACCESS".
the message seems vary between this two everytime i debug. This is my first time using NSZombiesEnabled. Do you see any thing wrong in this?
精彩评论