如何检查字段中的值并达到不同的目的。
如图所示,如果VIP值为0,则显示"VIP";无法前往";
检查VIP值是否为1,然后转到查看
我该怎么做才能实现
这是我当前的代码
let UID = Auth.auth().currentUser?.uid
let db = Firestore.firestore()
let docRef = db.collection("Users").document(UID!)
docRef.getDocument { (document, error) in
if error != nil {
self.showMsg(message: "no")
}else{
let array = document!.get("vip") as! String
switch array {
case "0":
self.showMsg(message: "0")
case "1":
self.showMsg(message: "1")
default:
print("the other city")
}
}
}
}
let UID = Auth.auth().currentUser?.uid
let db = Firestore.firestore()
let docRef = db.collection("Users").document(UID!)
docRef.getDocument { (document, error) in
if error == error {
print ("Error Occurs")
} else {
let array = document.data["vip"] as! String
switch array {
case "0":
self.showMsg(message: "0")
case "1":
self.showMsg(message: "1")
default:
print("the other city")
}
}
}
}