ios tableview cell 側滑刪除
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
returnTRUE;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
returnUITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView
NSInteger row=[indexPath row];
NSString *path = [NSStringstringWithFormat:@"%@/Documents/save.dat", NSHomeDirectory()];
NSData *data1 = [NSData dataWithContentsOfFile:path];//讀取檔案
NSMutableArray* array1 = [NSKeyedUnarchiverunarchiveObjectWithData:data1];//反序列化
[array1 removeObjectAtIndex:row];
NSMutableArray* array=[[NSMutableArrayalloc]initWithArray:array1];
NSData* data2=[NSKeyedArchiverarchivedDataWithRootObject:array];
[data2 writeToFile:path atomically:YES];
_datalist
[_tablereloadData];
}
在上面的函式裡面寫資料更新的操作。。。。。