views:

29

answers:

0

I have a working searchview Controller which show me all matching entries when I insert a letter. It's working fine.

If the search is empty, the Controller shows nothing. How can I change this? I want that it shows all entries of the filteredlistcontent-array when the searchtext is empty.

Therefore I changed the filterContentForSeracText method to this:

 (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{

 [self.filteredListContent removeAllObjects]; // First clear the filtered array.
 iCowAppDelegate *appDelegate = (iCowAppDelegate *)[[UIApplication sharedApplication]  
 delegate];


for (gericht *gerichtt in [appDelegate gerichteArray])
{
  if([searchText isEqualToString:@""] || [scope isEqualToString:@""] ) 
  {

   NSLog(@"SHOWALLENTRIES");
   [self.filteredListContent addObject:gerichtt];
  } else {

  NSComparisonResult result = [gerichtt.gerichteName compare:searchText 
  options: (NSCaseInsensitivePredicateOption|NSDiacriticInsensitivePredicateOption)  
  range:NSMakeRange(0, [searchText length])];

       if (result == NSOrderedSame)
       {
      NSLog(@"NOTSHOWALLENTRIES");

       [self.filteredListContent addObject:gerichtt];
       }
  }
 }
 [self.filteredListContent count];
 NSLog(@"Countz: %i",[self.filteredListContent count]);
 }

The NSLog Output shows me that the filteredListContent array is full of all Items, but the cellForRowAtIndexPath method doesn't start.

How can I fix this?