是否可以使用Firebase查询2次?我首先想将得分最高的帖子放在首位,然后再像我一样过滤他们的年龄。如果运行此命令,则会收到“线程1:信号SIGABRT”错误。我怎样才能解决这个问题?
func observeAllAgePosts(completion: @escaping (Post) -> Void) {
REF_POSTS.queryOrdered(byChild: "points").queryStarting(atValue: 0)
.queryEnding(atValue: 100000).queryOrdered(byChild: "Age").queryStarting(atValue: Age11)
.queryEnding(atValue: Age22).observeSingleEvent(of: .value, with: {
snapshot in
if snapshot.hasChildren(){
let arraySnapshot = (snapshot.children.allObjects as! [DataSnapshot]).reversed()
arraySnapshot.forEach({ (child) in
if let dict = child.value as? [String: Any] {
let post = Post.transformPostPhoto(dict: dict, key: child.key)
completion(post)
}
})
}else{
ProgressHUD.dismiss()
}
})
}
我的结构: