【发布时间】:2017-04-24 04:27:00
【问题描述】:
我正在尝试检查在我的应用中输入的用户名是否与我的 Firebase 数据库中的任何用户名匹配,如果是,请显示标签并禁用继续搜索/按钮。
相反,我得到一个持续的错误:
signal SIGABRT (lldb) // for app delegate
这是我的代码: @IBAction func checkUsernameEntered(_ sender: UITextField) {
let ref = FIRDatabase.database().reference(fromURL: "DATABASE_URL")
ref.child("users")
.queryOrdered(byChild: "kid/username")
.queryEqual(toValue: chooseUsernameTextField.text)
.observeSingleEvent(of: .value, with: { snapshot in
if !snapshot.exists(){
print("The username entered has not been previously registered. Tap 'Next' to proceed.")
self.bottomNextButtonThree.isEnabled = true
UIView.animate(withDuration: 0.6, delay: 0, options: .curveEaseOut, animations: { self.uhOhWarningLabel.alpha = 0 }, completion: nil)
}
else
{
print("The entered username has been previously registered. Re-enter to proceed.")
self.bottomNextButtonThree.isEnabled = false
UIView.animate(withDuration: 0.6, delay: 0, options: .curveEaseOut, animations: { self.uhOhWarningLabel.alpha = 1.0 }, completion: nil)
}
})
这是我在 firebase 上的数据库结构
感谢任何帮助
【问题讨论】:
-
我确定您是否可以使用 queryOrdered 中的斜杠进行这样的查询。试试
ref.child("users/kid").queryOrdered(byChild: "username").queryEqual(toValue: chooseUsernameTextField.text) -
我以不同的方式查询它,但我仍然从 xcode 收到错误:( 在 appDelegate 的 sigABRT 上
-
很奇怪。你确定是因为查询?如果你删除它,一切都好吗?
-
您在何处/何时调用此函数?确保在尝试访问
FIRDatabase.database().reference之前已在 AppDelegate 中调用FIRApp.configure()
标签: ios swift firebase swift3 firebase-realtime-database