【发布时间】:2017-10-31 16:14:01
【问题描述】:
我想尝试使用 Firebase Cloud Firestore 使用以下代码获取一些数据。
按下按钮应该获取一个布尔值,如果它满足某些条件,应用程序将导航到另一个视图控制器,它在第一次单击时工作正常,但我注意到当我导航返回并按下同一个按钮时,不会有任何结果又来了!!
db.collection("users").document((Auth.auth().currentUser?.uid)!).getDocument { (snap, error) in
if error != nil {
print(error.debugDescription)
}
if snap != nil {
let isPosted = snap?.data()["isPosted"] as! Bool
let isStroe = snap?.data()["isStore"] as! Bool
if !isPosted && !isStroe {
print("first post")
let useraccountVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "newData") as! UINavigationController
self.present(useraccountVC, animated: true, completion: nil)
}else if isPosted && isStroe {
print("store")
let useraccountVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "newData") as! UINavigationController
self.present(useraccountVC, animated: true, completion: nil)
}else if !isPosted && isStroe{
print("store")
let useraccountVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "newData") as! UINavigationController
self.present(useraccountVC, animated: true, completion: nil)
}else{
print("cant post any more")
}
}
}
【问题讨论】:
标签: swift google-cloud-firestore