swift - 如何快速检索唯一 ID 以将其删除(Firebase)
问题描述
我如何能够快速访问 Firebase 的唯一 ID?我已经尝试了这个论坛的几乎所有内容,我正在尝试快速删除表格单元格中的某个节点:
我尝试从用户电子邮件创建引用,并在字典中检索 ID,但是当我尝试从“indexPath”引用它时,它返回 ID。
我尝试了一个 int、string、any 类型的 Array;那些对我大喊大叫的人。
我已经包含了一些示例代码:
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
var currentEmail = Auth.auth().currentUser?.email as String?
if(editingStyle == .delete) {
let ref = Database.database().reference()
ref.child(currentEmail!).observe(.value, with: { snapshot in
if !snapshot.exists() {return} //may want to add better error handling here.
let info = snapshot.value as! NSDictionary
let reff = info.index(ofAccessibilityElement: indexPath)
print("info keys are:", reff)
})
}
解决方案
你试过snapshot.key吗?例子:
self.uid = 快照.key
推荐阅读
- xgboost - Optuna pdf 使用 dtrain = lgb.Dataset(train_x, label=train_y) - 但是 xgb 的等价物是什么
- flutter - Flutter:如何擦除/擦除/重置整个 CustomPaint 画布
- android - 发现任务 ':app:processDebugManifest' 的配置有问题(类型 'ProcessMultiApkApplicationManifest')
- python - wsq 解码错误:警告:hufftable 中的代码包含全 1 的代码
- oracle - Oracle中数字数据类型的默认精度
- flask - ModuleNotFoundError:没有名为“flask_sqlalchemy”的模块(即使我已经安装了 Flask-SQLAlchemy)
- c - c中mandelbrot程序的OpenMP问题
- sql - SQL SNOWFLAKE 中的 PIVOT 函数
- scala - 如何将 (String, Array[String]) 映射到 (String, String)
- javascript - Wordpress JS:在管理页面中添加后获取类别 ID