Sunday, 18 August 2013

UITableView deleting from SQLite database

UITableView deleting from SQLite database

I have these lines of code to delete a row in table view. the Table view
shows that the item has been deleted,but when I refresh the table, all of
my content comes again. Here is my code:
- (IBAction)deleting:(id)sender {
[[self tableView]setEditing:!self.tableView.editing animated:YES];
}
-(void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[entries removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
}
}
-(void)deleteData:(NSString *)deleteQuery
{
char *error;
if (sqlite3_exec(db, [deleteQuery UTF8String], NULL, NULL,
&error)==SQLITE_OK) {
NSLog(@"Person deleted");
}
}
Can you help me please? Thanks a lot :)

No comments:

Post a Comment