我有多个用户,我希望显示他们发布的每个图像或视频...现在问题是,在firebase数据库中只添加了最后一个ID我尝试了不同的方法和算法,没有看到工作
var friendsArray = [String]()
var fetchID : String?
for i in 0...friendsArray.count{
friendsArray.append(fetchFriend.id!)
let id = friendsArray[i]
fetchID = id
}
print(fetchID)
FIRDatabase.database().reference().child("users").child(fetchID!).observeEventType(.ChildAdded, withBlock: { (snapshot) in
var videos = [Video]()
for child in snapshot.children {
let dictionary = snapshot.childSnapshotForPath(child.key)
let userChannel = UserChannel()
userChannel.profileImageName = fetchFriend.profileImage
userChannel.username = fetchFriend.username
let video = Video()
video.thumbnailImageName = dictionary.value!["imageURL"] as? String
video.userChannel = userChannel
videos.append(video)
videos = videos.reverse()
dispatch_async(dispatch_get_main_queue(),{
completion(videos)
})
}
}, withCancelBlock:nil)
}