【发布时间】:2017-04-23 12:47:08
【问题描述】:
Pictures
-pictureID
-- name
-- date
Like
-pictureID
-- userID: true
-- userID: true
likePerUser
-userID
--pictureID: true
--pictureID: true
Users
-userID
-- name
-- lastname
我想检索当前用户喜欢的所有图片。
我做到了:
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 每次都有正确的值, 我总是得到一个错误:
无法将“__NSCFBoolean”(0x110dae5b8) 类型的值转换为 'NSDictionary' (0x110daf288)。
请帮忙....
【问题讨论】:
-
如果您想获得帮助,请修复您的代码并告诉我们错误发生在哪里。
标签: ios swift firebase firebase-realtime-database