I'm looking to have a searchbar where a user can search through users on Firebase and have a tableview updating as they type instead of just searching for exact matches.
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
if searchBar.text == nil || searchBar.text == "" {
inSearchMode = false
tableView.reloadData()
} else {
inSearchMode = true
let lower = searchBar.text!.lowercaseString
filteredPeopleArray = peopleArray.filter({$0.title.hasPrefix(lower) != nil})
tableView.reloadData()
}
This code works for that, but what this would require is on load for me to fill an array with every single user currently on firebase and to constantly be appending new users as they're being created while the app is open.
I see that parse used to have a "find users where key contains string" and you would do a query to parse in your textDidChange, but I'm not seeing anything like that for Firebase. Also, would that not be taxing on data in any way to send a query to firebase every time a letter is typed in?
What method is used by like Instagram for example where you type in some letters and return back a list of users from a server with that prefix in their name? So like "Bo" might return a list of bobs and bobbys.