【发布时间】:2017-10-14 03:55:25
【问题描述】:
我在 iOS 应用上使用 firebase 数据库!我写的很快。我正在使用“发送”按钮在我的 firebaseDatabase 上写入数据(例如 textField 和标签值)。有什么方法可以接受或拒绝我的数据库中的数据?我的意思是,如果用户向文本字段添加内容并按发送(这意味着将其添加到我的数据库中),我想在将其添加到我的数据库之前接受或拒绝它!
我的按钮操作:
@IBAction func saveBtn(_ sender: Any) {
//Saving item to database
if commentTextField.text != "" && placeLabel.text != "Location"
{
let place = placeLabel.text
let key = dbRef!.child("placeLabel").childByAutoId().key
dbRef!.child(place!+"/placeLabel").child(key).setValue(place)
dbRef!.child(place!+"/comment").child(key).setValue(commentTextField.text)
dbRef!.child(place!+"/rating").child(key).setValue(ratingControl.rating)
commentTextField.text = ""
//alert
createAlert(title: "Thank you!", message: "Review submitted.")
self.navigationController?.popViewController(animated: true)
}else{
//alert
createAlert(title: "Why don't write a review?", message: "Please write a review.")
}
}
【问题讨论】:
-
如果我的回答有帮助,请采纳。
标签: ios swift firebase firebase-realtime-database firebase-security