title: IOS error while using a search bar
body: <p>Hi in my app I've a TableView in which I show something and I want to search in this TableView for a text I write in the search bar, so I followed this <a href="http://www.raywenderlich.com/16873/how-to-add-search-into-a-table-view" rel="nofollow noreferrer">tutorial</a>.
  In my app I'm having a problem, when I run the app and I try to search a letter it crash and in xCode I see this information: <code>Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&lt;__NSCFString 0x9e45990&gt; valueForUndefinedKey:]: this class is not key value coding-compliant for the key name.'</code>. I checked my Storyboard to see if I have something wrong, but it's all ok. So I guess the problem it's in the code, I will post here my code and I hope you can help me what's wrong.</p>
  
  <pre><code>#import "TableWasteViewController.h"
  #import "WasteXmlParser.h"
  #import "WasteDetailViewController.h"
  
  @interface TableWasteViewController ()
  
  @property(nonatomic,strong)NSArray *arrayWastes;
  @property(nonatomic,strong)NSMutableArray *typeOfWaste;
  @property(nonatomic,strong)NSMutableArray *typeOfBin;
  @property(nonatomic,strong)NSMutableArray *indexWastes;
  @property(nonatomic,strong)NSMutableArray *typeOfWasteBackup;
  
  @end
  
  @implementation TableWasteViewController
  @synthesize searchBar;
  @synthesize filteredWasteArray;
  @synthesize typeOfWaste;
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
      if (self) {
          // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
      WasteXmlParser *parser = [[WasteXmlParser alloc]init];
      [parser parseWasteXml];
      self.arrayWastes = [[NSArray alloc]init];
      self.arrayWastes = [parser.arrayWastes mutableCopy];
      self.indexWastes = [[NSMutableArray alloc]init];
      typeOfWaste = [[NSMutableArray alloc]init];
      self.typeOfBin = [[NSMutableArray alloc]init];
      for (int i = 0; i &lt; [self.arrayWastes count]; i++) {
          [typeOfWaste addObject:[self.arrayWastes[i] objectForKey:@"type"]];
      }
  
      self.filteredWasteArray = [NSMutableArray arrayWithCapacity:[self.typeOfWaste count]];
  
      self.typeOfWasteBackup = [self.typeOfWaste mutableCopy];
  }
  
  #pragma mark Content Filtering
  - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope {
      [self.filteredWasteArray removeAllObjects];
  
      NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.name contains[c] %@", searchText];
      filteredWasteArray = [NSMutableArray arrayWithArray:[typeOfWaste filteredArrayUsingPredicate:predicate]];
  }
  
  #pragma mark - UISearchDisplayController Delegate Methods
  - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
      [self filterContentForSearchText:searchString scope:
       [[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
      return YES;
  }
  
  - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption {
      [self filterContentForSearchText:self.searchDisplayController.searchBar.text scope:
       [[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:searchOption]];
      return YES;
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      //return self.arrayWastes.count;
      if (self.tableWaste == self.searchDisplayController.searchResultsTableView) {
          return [filteredWasteArray count];
      } else {
          return [self.arrayWastes count];
      }
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      UIFont *myFont = [UIFont fontWithName:@"Arial" size:14.0];
      if (cell == nil) {
           cell  = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
  
      cell.textLabel.font = myFont;
      cell.textLabel.numberOfLines = 2;
      //cell.textLabel.text = [self.arrayWastes[indexPath.row]objectForKey:@"type"];
      if (self.tableWaste == self.searchDisplayController.searchResultsTableView) {
          cell.textLabel.text = [self.filteredWasteArray[indexPath.row]objectForKey:@"type"];
      } else {
          cell.textLabel.text = [self.arrayWastes[indexPath.row]objectForKey:@"type"];
      }
      return cell;
  }
  
  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
      NSIndexPath *indexPath = [self.tableWaste indexPathForSelectedRow];
      WasteDetailViewController *vc = segue.destinationViewController;
      vc.typeOfWaste = [self.arrayWastes[indexPath.row]objectForKey:@"type"];
      vc.typeOfBin = [self.arrayWastes[indexPath.row]objectForKey:@"place"];
      vc.urlPic = [self.arrayWastes[indexPath.row]objectForKey:@"imgUrl"];
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
  }
  
  - (IBAction)backToHome:(id)sender {
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  @end
  </code></pre>
  
  <p>Thank you!</p>
  
  <p><strong>UPDATE</strong>
  I post here the screen of my storyboard in which you can see the connection of the tableview controller.</p>
  
  <p><img src="https://i.stack.imgur.com/HkUb8.png" alt="Connection for the WasteTableViewController"></p>