title: iPhone table view - problem with indexPath.row
body: <p>I'm using indexPath.row do determine in which row of my tableview I do something. The title of my cells is containing a number which should be 1 in the first row and 18 in the last row, so I have 18 rows. This works for the first 11 rows, but after that, I have numbers in the title which seem to be generated randomly! Sometimes 16, then 5, then 18, then 12... and so on. 
  What's the problem with it/why does the indexPath.row variable behave like that?</p>
  
  <p>My cellForRowAtIndexPath method:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
  static NSString *MyIdentifier = @"MyIdentifier";
  
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
  if (cell == nil) {
      [[NSBundle mainBundle] loadNibNamed:@"myCell" owner:self options:nil];
      cell = cell0;
      self.cell0 = nil;
  }
  UILabel *label;
  label = (UILabel *)[cell viewWithTag:1];
  label.text = [NSString stringWithFormat:@"Cell %d", indexPath.row];
  
  return cell;  
  </code></pre>
  
  <p>}</p>
  
  <p>Any more suggestions on how to solve the problem? I didn't get it working until now...</p>
  
  <p>// Update with more code:</p>
  
  <p>Here is how I declare the cell. It is in an XIB file (template "empty XIB") in which I just put the cell from the library in IB.</p>
  
  <pre><code>@interface myViewController : UITableViewController {
  
      UITableViewCell *cell0;
  }
  
  @property (nonatomic, retain) IBOutlet UITableViewCell *cell0;
  </code></pre>
  
  <p>Then, at the top of the myViewController.m file:</p>
  
  <pre><code>@synthesize cell0;
  </code></pre>
  
  <p>My cellForRowAtIndexPath method is already posted above. It is equal to the cellForRowAtIndexPath method in the SDK documentation, and in Apple's example, it seems to work. </p>