Scenario = I have an app that allows users to search for other users that use the service. In the search page there is a UISearchDisplayController that when a user begins typing in the search bar, a tableView will programmatically appear (just like any other UISearchDisplayController) and filter all of the users in the database depending on whats being typed ('begins-with'). So the user will begin typing, "B... r...." and users will begin to populate the tableView from "Brad" to "Brandon" and so on based on the text being inputted.
Question = How would one go about designing the parse query to achieve this effect?
Specific Questions =
1) When and Where to begin the initial query?...
PFQuery *searchQuery = [PFUser query];
[searchQuery whereKey:@"username" containsString:controller.searchBar.text];
[searchQuery orderByDescending:@"updatedAt"];
[searchQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
NSLog(@"%@", objects);
searchArray = objects;
}];
in "searchDisplayControllerDidBeginSearch"?
2) When and Where do I put the logic to fill in the tableView?
PFObject *searchObject = [searchArray objectAtIndexPath:indexPath.row];
cell.nameLabel.text = searchObject[@"name"];
in "cellForRowAtIndexPath"?
If there is anyone out there that knows this and can help me out Id appreciate it.