//覆盖支持编辑表格视图的方法
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
//“delete”编辑风格被提交
if (editingStyle == UITableViewCellEditingStyleDelete)
{
//删除位于indexPath.row的联系人
[contacts removeObjectAtIndex:indexPath.row];
//从数据源中删除该行
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
//把contacts写入文件
[contacts writeToFile:filePath atomically:NO];
}
}
UITableViewDataSource协议的tableView:commitEditingStyle:forRowAtIndexPath:方法在用户编辑表格时被调用,比如删除或者插入某一行。deleteRowsAtIndexPaths:withRowAnimation:方法从tableView中删除行。然后把联系人写入文件