【发布时间】:2017-03-11 03:19:14
【问题描述】:
我需要创建一个使用 firebase 作为后端的 UISearchController。我目前在 firebase 中有两个用户。一位用户发表了一篇文章,另一位发表了四篇文章。我希望能够在我的数据库中搜索所有书籍的标题(即五本书)。但是,到目前为止,我只能搜索当前登录用户上传的书籍。下面是我的数据库的截图和我的代码目前的截图。
databaseRef.child("posts").child(userID!).observe(.childAdded, with: { (snapshot) in
let key = snapshot.key
let snapshot = snapshot.value as? NSDictionary
snapshot?.setValue(key, forKey: "uid")
if(key == self.loggedUser?.uid)
{
print("same as logged in user")
}
else
{
self.usersArray.append(snapshot)
self.followUsersTableView.insertRows(at: [IndexPath(row:self.usersArray.count-1,section:0)], with: UITableViewRowAnimation.automatic)
}
}) { (error) in
print(error.localizedDescription)
}
}
【问题讨论】:
标签: ios swift firebase firebase-realtime-database