嗨,讓我直說:你的數據源實際上是在線的,你需要確認它在你更新你的tableview之前被刪除 - 同時你想顯示一個AI活動指示器。
如果這是你想要做什麼,然後你用這種方法
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Get the key of the data you want to delete.
data_struct_instance * data = [self.mutableArray_data_source objectForRowAtIndexPath:indexPath];
NSString *data_key = data.key;
row_index = indexPath.row; // set a property to preserve the row (or index path for multilevel data) for use when you delete the the record later.
[self start_UIActivityIndicator];
[self callonline_with_delete_command:data_key]; // send the request to delete the record
}
啓動一次服務器取決於它是否是成功的響應,或者不是你可以刪除記錄或重新加載,如果整個陣列表小是爲了確保數據同步 -
....
[activityindicator StopAnimating];
if (success) {
[self.mutableArray_data_source removeObjectAtIndex:row_index];}
else {
NSLog ....
}
[self.tableView reloadData]; // resets the delete button.
check in didFinishLoading and reload the table ... –