【问题标题】:How can I delete my data at firebase Realtime Database?如何在 firebase 实时数据库中删除我的数据?
【发布时间】:2019-09-11 08:00:37
【问题描述】:

我有一个tableview,当我点击删除它从tableview中删除但我还需要从firebase实时数据库中删除我该怎么做?

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {

    NSString *uuid = self.firebaseUidArray[indexPath.row];
    [[[self.taskRef child:@"tasks"] child:uuid] removeValueWithCompletionBlock:^(NSError * _Nullable error, FIRDatabaseReference * _Nonnull ref) {
        [self.tasks removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateTableViewForDeleting" object:nil];
    }];

}

【问题讨论】:

    标签: ios objective-c uitableview firebase-realtime-database


    【解决方案1】:

    如果你知道要删除的项目的key,你可以使用写操作setValue并将它设置为nil它将被删除

    [[[self.taskRef child:@"tasks"] child:uuid] setValue:nil];
    

    【讨论】:

      猜你喜欢
      • 2016-09-20
      • 1970-01-01
      • 2018-12-07
      • 1970-01-01
      • 2021-09-20
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多