我是iOS开发的新手,我通过使用childByAutoId()将一大块数据存储到firebase数据库,在此下面存储用户名,photoURL,textMessage和用户UID.我正在tableView Cells中检索这些数据.现在我想要的是当我点击其中一个帖子或tableView单元格时,我想打印由childByAutoId()函数生成的唯一ID.这该怎么做.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let name = Auth.auth().currentUser?.displayName
let indexPath = tableView.indexPathForSelectedRow
let alertController = UIAlertController(title: "Trial", message: "You Selected "+name!, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "Close Alert", style: .default, handler: nil)
alertController.addAction(defaultAction)
present(alertController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码来捕获单元格上的点击.那么什么代码有助于在点击后获取该特定单元格的子ID?我想在日志中打印它.
这就是我的列表的样子.