title: UITableView crashes when scrolling
body: <p>I've been attempting to create my own app for a band by my friends, and I've been experimenting with using a custom TableViewCell for news articles that appear on the website.  My main objective is to get all of the data from the website, store it in a NSMutableArray, and then display that in my custom cells.  </p>
  
  <p>The app runs fine when it loads the first 5-6 cells.  However, when I begin to scroll, the app crashes.  I've pinpointed the in the <code>cellForRowAtIndexPath:</code> method.  Using GDB, I've also come to find out that after I create my NSMutableArray data and once the program runs, after scrolling, my array seems to be autoreleased.  I'm not sure why this happens.  Here's what I have for my code thus far:</p>
  
  <p>In HomeViewController.h:</p>
  
  <pre><code>@interface HomeViewController : UIViewController {
      NSArray *results;
      NSMutableArray *titles;
      NSMutableArray *dates;
      NSMutableArray *entries;
  }
  
  @property (nonatomic, retain) NSMutableArray *titles;
  @property (nonatomic, retain) NSMutableArray *dates;
  @property (nonatomic, retain) NSMutableArray *entries;
  
  @end
  </code></pre>
  
  <p>In HomeViewController.m:</p>
  
  <pre><code>- (void)viewDidLoad {
  [super viewDidLoad];
  titles = [[NSMutableArray alloc] init];
  dates = [[NSMutableArray alloc] init];
  entries = [[NSMutableArray alloc] init];
  
  while((i+1) != endIndex){   
      NSString *curr_title = [[NSString alloc] init]; 
      NSString *curr_date = [[NSString alloc] init];
      NSString *curr_entry = [[NSString alloc] init];
  
      //do some character iterations across a string
  
      [titles addObject:curr_title];
      [dates addObject:curr_date];
      [entries addObject:curr_entry];
  
      [curr_title release];
      [curr_date release];
      [curr_entry release];
  }
  }
  </code></pre>
  
  <p>//more code here, removed</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
  static NSString *CellIdentifier = @"NewsCell";
  
  
  NewsCell *cell = (NewsCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
  if (cell == nil) {
      NSArray *topLevelObjects = [[NSBundle mainBundle]
                                  loadNibNamed:@"NewsCell"
                                  owner:self options:nil];
  //  cell = [topLevelObjects objectAtIndex:0];
      for(id currentObject in topLevelObjects){
          if([currentObject isKindOfClass:[UITableViewCell class]]){
              cell = (NewsCell *)currentObject;
              break;
          }
      }
  
  }
  NSLog(@"%d", indexPath.row);
  NSLog(@"%d", titles.count);
  cell.cellTitle.text = [titles objectAtIndex:indexPath.row];
  cell.datePosted.text = [dates objectAtIndex:indexPath.row];
  cell.preview.text = [entries objectAtIndex:indexPath.row];
  
  return cell;
  }
  </code></pre>
  
  <p>Again, the first 5-6 cells show up.  Once I scroll, I tried doing <code>po titles</code> and got this error:</p>
  
  <p><code>Program received signal EXC_BAD_ACCESS, Could not access memory.
  Reason: KERN_PROTECTION_FAILURE at address: 0x00000009
  0x011b309b in objc_msgSend ()</code></p>
  
  <p>I've tried allocating the arrays in <code>initWithNibName:</code> but that didn't seem to do much.  I've tried moving all the code in <code>viewDidLoad:</code> and then calling <code>[super viewDidLoad]</code> and it just produced the same results as well.  Sorry this is so long, but I figured people needed to see my code.</p>