Pictures
-pictureID
-- name
-- date
Like
-pictureID
-- userID: true
-- userID: true
likePerUser
-userID
--pictureID: true
--pictureID: true
Users
-userID
-- name
-- lastname
現在のユーザーが好きなすべての画像を取得したいと思います。Firebase iOS他のノードからのデータでお気に入りのリストを取得する
私でした:それはfirstIdは毎回、 を正しい値を持っていると思われる場合は
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)
}
でも、私は常にエラーを取得:
Could not cast value of type '__NSCFBoolean' (0x110dae5b8) to 'NSDictionary' (0x110daf288).
が助けてくださいを....
助けを求めている場合は、コードを修正し、エラーの発生場所を教えてください。私はあなたが私を示唆したものを印刷する場合の答えのための – SahandTheGreat