ref = Database.database().reference()
let currentUserID = Auth.auth().currentUser?.uid
let userRef = ref.child("users").child(currentUserID!)
let userRefQuery = userRef.queryOrdered(byChild: "requests").queryEqual(toValue: "received")
userRefQuery.observeSingleEvent(of: .value, with: { (snapshot) in
if (snapshot.value is NSNull) {
print("no data found")
return
}
print("value:")
print(snapshot.value)
print("key:")
print(snapshot.key)
})
如何在“请求”下获取具有“已接收”值的用户的用户ID。因为它也可能被“发送”。目前,我没有收到任何数据!
答案 0 :(得分:0)
这就是我的工作方式:
ref = Database.database().reference()
let currentUserID = Auth.auth().currentUser?.uid
refHandle = ref.child("users").child(currentUserID!).observe(.value, with: { (snapshot) in
print(snapshot)
if let userDict = snapshot.value as? [String: Any] {
if let requests = userDict["requests"] as? [String: String] {
print(requests)
for request in requests {
if request.value == "sent" {
self.userIDs.append(request.key)
print(request.key)
}
}
}
}
}
答案 1 :(得分:0)
对于您删除的问题,而不是:
char temp = s[start]
做
char temp = s[i];