1
私は以下のコードスニペットを使用しています。エラーが発生した場合は、エラーメッセージが表示された後、再試行ボタンを表示します。ただし、エラーが発生すると、エラーはログに出力されますが、ラベルとボタンは表示されません。何か不足していますか?Swift Firebaseデータベースエラー処理
user_ref = Database.database().reference(withPath: "userdetails")
self.user_ref.observe(.value, with: { snapshot in
if !snapshot.exists() { return }
let snapshotValue = snapshot.value as? NSDictionary
if let temp_usertype = snapshotValue?["usertype"] as? String {
usertype = temp_usertype
}
self.user_ref.removeAllObservers()
self.close()
})
{(error) in
print(error.localizedDescription)
self.lblMessage.text = "\(error.localizedDescription)"
self.btnRetry.isEnabled = true
self.btnRetry.alpha = 1.0
return
}
どのように動作するかについてご質問がある場合は、このページをご覧ください。 https://github.com/JZDesign/OnTheMap/blob/master/OnTheMap/Client.swift – Jake