I'd like to make a search bar, and if I get the search word, I'd like to get the data which include the word on firebase.
I've already implimented a search bar and am looking for what I have to write in func searchBarSearchButtonClicked(_ searchBar: UISearchBar)
.
So far, I have an idea. It uses "for" and "if" to run code like this to get data.
for i in (~) {
let defaultPlace = DBRef.child("posts/\(i)/age")
defaultPlace.observe(.value) { (snap: FIRDataSnapshot) in
if ~ {
self.displayAge.text = (snap.value! as AnyObject).description
}
}
}
(↑ this is just an example. "~" is something)
But I'm not sure if it's really the best way.