title: tableview with 3 sections crashed when scrolling down
body: <p>I am creating a tableview with 3 sections and each section is being populated from a Multidimentional NSMutableArray. The values are added to the mutable array but the app crashes every time i try to set texts to the labels in each section. Here is the code:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
  NSLog(@"wsolna hon");
  static NSString *cellIdentifier = @"HomeTableViewCell";
  HomeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
  
  // Configure the cell...
  int row= [indexPath row];
  
  
                  if (indexPath.section == 0){
                       homeObject = [homeArray[0] objectAtIndex:indexPath.row];
  
                          NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[homeObject.News dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
                      cell.NewsDateLabel.text= homeObject.News_Date;
                      cell.NewsLabel.attributedText= attrStr;
                      NSLog(@"news: %@", homeObject.News);
  
                  }
  
  
                  if (indexPath.section == 1){
  
                      homeObject = [homeArray[1] objectAtIndex:indexPath.row];
  
                     NSLog(@"value of indexpath for library: %d",row);
                     cell.NewsLabel.text= homeObject.Library_text;
                     cell.TestimonialNameLabel.text= @"";
                  NSLog(@"Library: %@", homeObject.Library_text);
              }
  
                  if (indexPath.section == 2){
                      homeObject = [homeArray[2] objectAtIndex:indexPath.row];
  
                       NSLog(@"news: %@",homeObject.Testimonial_Description);
                       cell.NewsLabel.text= homeObject.Library_text;
                       cell.TestimonialNameLabel.text = homeObject.Testimonial_Name;
                      NSLog(@"Testimonial: %@", homeObject.Testimonial_Description);
  
              }
  
  
  
    return cell;
   }
  </code></pre>
  
  <p>//here is where the NSMutable array is being filled
       - (void) getDataFromDb
       {</p>
  
  <pre><code>NSString * paths=[self getWritableDBPath];
  
  const char *dbpath =  [paths UTF8String];
  sqlite3_stmt    *statement;
  static sqlite3 *database = nil;
  
  if (sqlite3_open(dbpath, &amp;database) == SQLITE_OK)
  {
  
      NSString *querySQL = [NSString stringWithFormat: @"SELECT * FROM homedata", nil];
  
      const char *query_stmt = [querySQL UTF8String];
  
      //  NSLog(@"Databasae opened = %@", userN);
  
      if (sqlite3_prepare_v2(database,
                             query_stmt, -1, &amp;statement, NULL) == SQLITE_OK)
      {
  
          while(sqlite3_step(statement) == SQLITE_ROW)
          {
  
  
              NSString *modID= [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 1)];
              NSString *nDate = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 4)];
              NSString *nText = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 2)];
              NSString *dText = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 2)];
              NSString *tText = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 2)];
              NSString *tName = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 3)];
  
              if ([modID isEqualToString:@"77"]){
                //  NSLog(@"News found: %@", nText);
                  [homeArray[0] addObject:[[Home alloc]initWithItemID: modID andNewsName:nText andNewsDate: (NSString *) nDate andLibraryText: dText andTestDescription: tText andTestimonialName: (NSString *) tName]];
              } else if ([modID isEqualToString:@"81"]){
                  [homeArray[1] addObject:[[Home alloc]initWithItemID: modID andNewsName:nText andNewsDate: (NSString *) nDate andLibraryText: dText andTestDescription: tText andTestimonialName: (NSString *) tName]];
                //   NSLog(@"Library found: %@", dText);
              } else if ([modID isEqualToString:@"78"]){
                  [homeArray[2] addObject:[[Home alloc]initWithItemID: modID andNewsName:nText andNewsDate: (NSString *) nDate andLibraryText: dText andTestDescription: tText andTestimonialName: (NSString *) tName]];
                //   NSLog(@"News found: %@", tText);
              }
          }
          sqlite3_finalize(statement);
      }
      //  NSLog( @"Save Error: %s", sqlite3_errmsg(database) );
  
      sqlite3_close(database);
  }
   }
  </code></pre>
  
  <p>and in ViewDidLoad i have:</p>
  
  <pre><code>homeArray = [[NSMutableArray alloc] initWithObjects:[[NSMutableArray alloc] init], [[NSMutableArray alloc] init], [[NSMutableArray alloc] init], nil];
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
    return 3;
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
  if (section == 0)
  {
      NSLog(@"woslit 3al 1");
      NSString *querySQL = [NSString stringWithFormat: @"SELECT count(*) FROM homedata where module_ID= 77"];
      return [self countcells:querySQL];
  }
  if(section == 1)
  {
        NSLog(@"woslit 3al 2");
      NSString *querySQL = [NSString stringWithFormat: @"SELECT count(*) FROM homedata where module_ID= 78"];
      return  [self countcells:querySQL];
  }
  
  if (section == 2)
  {
       NSLog(@"woslit 3al 3");
    return[self countcells:@"SELECT count(*) FROM homedata where module_ID= 81"];
  }
   else return 0;
  }
  -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  
  //TEMP SECTION STRING HOLDER:
  NSString *sectionHeader = nil;
  
  
  //SET TITLE FOR EACH SECTION:
  if(section == 0) {
      sectionHeader = @"News";
  }
  
  if(section == 1) {
      sectionHeader = @"TYM Library";
  }
  
  if(section == 2) {
      sectionHeader = @"Testimonial";
  }
  </code></pre>
  
  <p>I am able to get the values when i use NSLog. but when i  slide down it crashes.
  Can someone please check where the problem might be?
  Thanks!</p>