title: TableView not showing anything after keying in the second letter into search bar
body: <p>I used json parsing and managed to fetch information from a website and show it in the Table View. I managed to set up the search bar such that it searches for the text. However when i key in my second letter there is nothing in the table view even though there is words starting with the two letters. I have added my code below.</p>
  
  <pre><code>@implementation EventsTableViewController
  @synthesize searchBar, filteredEventsArray, eventNamesArray, isFiltered, eventsDictionary;
  
  - (id)initWithStyle:(UITableViewStyle)style
  {
      self = [super initWithStyle:style];
      if (self) {
          // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.eventNamesArray = [NSMutableArray array];
      self.eventsDictionary = [NSMutableDictionary dictionary];
  }
  
  - (void)viewWillAppear:(BOOL)animated
  {
      [super viewWillAppear:animated];
  
      [self searchForEvents];
  }
  
  //Json Parsing
  - (void)searchForEvents
  {
  
  
      NSString *eventsSearchUrlString = [NSString stringWithFormat:@"https://www.googleapis.com/blogger/v3/blogs/1562818803553764290/posts?key=AIzaSyBTOxz-vPHgzIkw9k88hDKd99ILTaXTt0Y"];
      NSURL *eventsSearchUrl = [NSURL URLWithString:eventsSearchUrlString];
      NSURLRequest *eventsSearchUrlRequest = [NSURLRequest requestWithURL:eventsSearchUrl];
  
      NSURLSession *sharedUrlSession = [NSURLSession sharedSession];
      NSURLSessionDataTask *searchEventsTask =
      [sharedUrlSession dataTaskWithRequest:eventsSearchUrlRequest completionHandler:
       ^(NSData *data, NSURLResponse *response, NSError *error)
       {
           dispatch_async(dispatch_get_main_queue(),
                          ^{
                              [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
  
                              if(error)
                              {
                                  UIAlertView *searchAlertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please check your internet connection" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                                  [searchAlertView show];
                              }
                              else
                              {
                                  NSString *resultString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                                  NSLog(@"Search results: %@", resultString);
  
                                  NSError *jsonParseError = nil;
                                  NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&amp;jsonParseError];
  
                                  if(jsonParseError)
                                  {
                                      UIAlertView *jsonParseErrorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:jsonParseError.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                                      [jsonParseErrorAlert show];
                                  }
                                  else
                                  {
                                      for(NSString *key in jsonDictionary.keyEnumerator)
                                      {
                                          NSLog(@"First level key: %@", key);
                                      }
  
                                      [self.eventNamesArray removeAllObjects];
                                      [self.eventsDictionary removeAllObjects];
  
                                      NSArray *searchResultsArray = [jsonDictionary objectForKey:@"items"];
                                      //NSLog(@"test%@",searchResultsArray);
  
  
                                      for(NSDictionary *eventsInfoDictionary in searchResultsArray)
                                      {
                                          Events *event = [[Events alloc] init];
                                          event.eventName = [eventsInfoDictionary objectForKey:@"title"];
                                          event.eventDescription =[eventsInfoDictionary objectForKey:@"content"];
  
                                          NSLog(@"Event Name : %@",event.eventName);
                                          NSLog(@"Event Description : %@",event.eventDescription);
  
                                          NSString *eventsAsStrings = [event.eventName substringToIndex:1];
                                          NSMutableArray *eventsInArray = [self.eventsDictionary objectForKey:eventsAsStrings];
  
                                          if(!eventsInArray)
                                          {
                                              eventsInArray = [NSMutableArray array];
                                              [self.eventNamesArray addObject:eventsAsStrings];
                                          }
  
                                          [eventsInArray addObject:event];
  
                                          [self.eventsDictionary setObject:eventsInArray forKey:eventsAsStrings];
  
                                          if ([event.eventDescription containsString:@"&lt;br /&gt;"]) {
                                              NSString* eventDescrip = event.eventDescription;
                                              NSString* stringWithoutHTMLtags = [eventDescrip stringByReplacingOccurrencesOfString:@"&lt;br /&gt;" withString:@""];
                                              event.eventDescription = stringWithoutHTMLtags;
                                          }
                                          NSLog(@"Event Name : %@",event.eventName);
                                          NSLog(@"Event Description : %@",event.eventDescription);
  
                                      }
  
                                      [self.eventNamesArray sortedArrayUsingComparator:^NSComparisonResult(Events *obj1, Events *obj2) {
                                          Events *time1 = obj1;
                                          Events *time2 = obj2;
                                          if (time1 &gt; time2) {
                                              return (NSComparisonResult)NSOrderedDescending;
                                          }
                                          else if (time1 &lt; time2) {
                                              return (NSComparisonResult)NSOrderedAscending;
                                          }
                                          return (NSComparisonResult)NSOrderedSame;
                                      }];
                                      [self.tableView reloadData];
                                  }
                              }
                          });
       }];
  
      [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
      [searchEventsTask resume];
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
      if (searchText.length == 0) {
          isFiltered = NO;
      }
      else {
          isFiltered = YES;
      }
      NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[c] %@",searchText];
      self.filteredEventsArray = [eventNamesArray filteredArrayUsingPredicate:pred];
      [self.tableView reloadData];
  }
  
  //- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
   //   [resign fi]
  //}
  
  #pragma mark - Table view data source
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
      if (isFiltered == YES) {
          return filteredEventsArray.count;
      }
      else {
          return self.eventNamesArray.count;
      }
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      NSArray *eventsWithFirstLetter;
      if (isFiltered == YES) {
          NSString *firstLetter = [self.filteredEventsArray objectAtIndex:section];
          eventsWithFirstLetter = [self.eventsDictionary objectForKey:firstLetter];
          return eventsWithFirstLetter.count;
      }
      else {
          NSString *firstLetter = [self.eventNamesArray objectAtIndex:section];
          eventsWithFirstLetter = [self.eventsDictionary objectForKey:firstLetter];
          return eventsWithFirstLetter.count;
      }
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"eventTitleCell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
      Events *event;
      if (isFiltered == YES) {
          NSString *firstLetter = [self.filteredEventsArray objectAtIndex:indexPath.section];
          NSArray *eventsWithFirstLetter = [self.eventsDictionary objectForKey:firstLetter];
          event = [eventsWithFirstLetter objectAtIndex:indexPath.row];
          cell.textLabel.text = event.eventName;
      }
      else {
          NSString *firstLetter = [self.eventNamesArray objectAtIndex:indexPath.section];
          NSArray *eventsWithFirstLetter = [self.eventsDictionary objectForKey:firstLetter];
          event = [eventsWithFirstLetter objectAtIndex:indexPath.row];
          cell.textLabel.text = event.eventName;
      }
      return cell;
  }
  
  -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  
      NSString *firstLetter = [self.eventNamesArray objectAtIndex:indexPath.section];
      NSArray *eventsWithFirstLetter = [self.eventsDictionary objectForKey:firstLetter];
      Events *event = [eventsWithFirstLetter objectAtIndex:indexPath.row];
  
      UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
      DescriptionViewController *descriptionViewController = (DescriptionViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"descriptionController"];
      descriptionViewController.eventNameDesc = event.eventDescription;
      descriptionViewController.navigationItem.title = event.eventName;
      [self.navigationController pushViewController:descriptionViewController animated:YES];
  
  }
  
  
  
  @end
  </code></pre>