Reputation: 7639
I am using a PFQueryTableViewController that should only load objects after a user has pressed a button. The problem is lying in the method - (PFQuery *)queryForTable
.
Here is my code:
- (PFQuery *)queryForTable
{
if (self.searchText) {
PFQuery *titleQuery = [PFQuery queryWithClassName:@"photo"];
[titleQuery whereKey:@"titleKey" containsString:self.searchText];
PFQuery *descriptionQuery = [PFQuery queryWithClassName:@"photo"];
[descriptionQuery whereKey:@"descriptionKey" containsString:self.searchText];
PFQuery *searchQuery = [PFQuery orQueryWithSubqueries:@[titleQuery, descriptionQuery]];
return stringSearchQuery;
}
return nil;
}
The problem is that I manually call - (void)loadObjects
at some other point when a user decides to. By returning nil in this method the PFQueryTableView just leaves the loading indicator on indefinitely and user interaction is disabled.
What do I need to return in order for the table view to just be blank and then after the user interaction will load?
Upvotes: 1
Views: 263
Reputation: 9942
Instead of checking whether searchText exists, try defaulting it to something that will never occur in the database, i.e. a dummy string like "@@@@@@@ Dummy string. Will never occur in database @@@@@@@".
This way, the query will be performed but not return any results - which should leave the tableview empty. Then, when the user enters a search string and taps the button, the queryForTable code is executed with real search string.
Upvotes: 2