Pictures
-pictureID
-- name
-- date
Like
-pictureID
-- userID: true
-- userID: true
likePerUser
-userID
--pictureID: true
--pictureID: true
Users
-userID
-- name
-- lastname
我想檢索當前用戶喜歡的所有圖片。Firebase iOS Swift從其他節點獲取數據的收藏夾列表
我所做的:
ref.child("likePerUser").child(FIRAuth.auth()!.currentUser!.uid).observeSingleEvent(of: .value, with: { (snap) in
for item1 in snap.children{
let firstItem1 = (snap: item1 as! FIRDataSnapshot)
print("key favourites\(firstItem1.key)")
let firstId = firstItem1.key
self.ref.child("pictures").child(firstId).observeSingleEvent(of: .value, with: { (snapshot) in
for item in snapshot.children{
let firstItem = (snapshot: item as! FIRDataSnapshot)
print("key pictures \(firstItem.key)")
let dict = firstItem.value as! [String: Any
let name = dict["name"] as! String
print(name)
}
甚至,如果它似乎firstId每次 具有正確的值,我總是得到一個錯誤:
Could not cast value of type '__NSCFBoolean' (0x110dae5b8) to 'NSDictionary' (0x110daf288).
請幫助....
如果你想得到一些幫助,修復你的代碼並告訴我們錯誤發生在哪裏。 – SahandTheGreat