Note that there are some explanatory texts on larger screens.

plurals
  1. POParse.com: Searching a TableView
    primarykey
    data
    text
    <p>Hey together I am using <a href="http://www.parse.com" rel="nofollow">Parse</a> SDK for my App - the interface is build in Storyboard...</p> <p>I am having a table view which get's his data from Parse, now I want to make it searchable.</p> <p>I found <a href="https://www.parse.com/questions/programmatic-search-capability-using-parse" rel="nofollow">this post</a> and followed it but not came to a running result! :/</p> <p>The search results are load but I having problems to display them...</p> <p>I get the following errors:</p> <pre><code>... myApp[..] *** Assertion failure in -[UISearchResultsTableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:5471 ... myApp[...] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' </code></pre> <p>I tried a lot around but don't come to a result, here is my code - can anybody help:</p> <p>Sorry for my bad english! ;)</p> <pre class="lang-cs prettyprint-override"><code>#import "FirstLaunchViewController.h" @interface FirstLaunchViewController () @end @implementation FirstLaunchViewController #pragma mark - UIViewController - (void)viewDidLoad { [super viewDidLoad]; [self loadObjects]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar_background.png"] forBarMetrics:UIBarMetricsDefault]; self.searchResults = [NSMutableArray array]; } - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithClassName:@"teams"]; self = [super initWithCoder:aDecoder]; if (self) { // The className to query on self.parseClassName = @"teams"; self.textKey = @"verein"; // The key of the PFObject to display in the label of the default cell style // self.keyToDisplay = @"text"; // Whether the built-in pull-to-refresh is enabled self.pullToRefreshEnabled = NO; // Whether the built-in pagination is enabled self.paginationEnabled = YES; self.loadingViewEnabled = NO; // The number of objects to show per page self.objectsPerPage = 50; } return self; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait || UIInterfaceOrientationIsLandscape(interfaceOrientation)); } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object { PFTableViewCell *cell = (PFTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell"]; // Configure the cell UIColor *color = [[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.0]; cell.detailTextLabel.backgroundColor = color; cell.textLabel.backgroundColor = color; cell.backgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cellbackground_n.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0]]; cell.selectedBackgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cellbackground_down_n.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0]]; cell.accessoryView = [[ UIImageView alloc ] initWithImage:[UIImage imageNamed:@"cellarrows.png" ]]; if (tableView == self.tableView) { cell.textLabel.text = [object objectForKey:@"verein"]; } else { PFUser *obj2 = [self.searchResults objectAtIndex:indexPath.row]; PFQuery *query = [PFQuery queryWithClassName:@"teams"]; PFObject *searchedUser = [query getObjectWithId:obj2.objectId]; NSString *content = [searchedUser objectForKey:@"verein"]; cell.textLabel.text = content; NSLog(@"Content: %@", content); } return cell; } -(void)filterResults:(NSString *)searchTerm { [self.searchResults removeAllObjects]; PFQuery *query = [PFQuery queryWithClassName: self.parseClassName]; [query whereKeyExists:@"verein"]; //this is based on whatever query you are trying to accomplish [query whereKey:@"verein" containsString:searchTerm]; NSArray *results = [query findObjects]; NSLog(@"%@", results); NSLog(@"%u", results.count); [self.searchResults addObjectsFromArray:results]; } -(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { [self filterResults:searchString]; return YES; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.tableView) { return self.objects.count; } else { return self.searchResults.count; } } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload