title: UITableViewController numberOfRowsInSection doesn't affect the actual number of rows
body: <p>The table I'm having problem with is pushed from another table controller, and there is only one section in this table, and I'm using custom cells. Here is the code for numberOfRowsInSection:</p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  NSInteger numberOfRows;
  if ([imagesArray count] == 0) {
      numberOfRows = 0;
  }
  else {
      if ([imagesArray count] % 4 == 0) {
          numberOfRows = [imagesArray count] / 4;
      }
      else {
          numberOfRows = ([imagesArray count] / 4) + 1;
      }
  }
  NSLog(@"numberOfRowsInSection: %d", numberOfRows);
  return numberOfRows;
  }
  </code></pre>
  
  <p>The log here always prints the expected number of rows. So far so good. Now let's take a look at cellForRowAtIndexPath:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      NSLog(@"cellForRowAtIndexPath: %@", [indexPath description]);
  
      ImageTableCell *cell = (ImageTableCell *)[tableView dequeueReusableCellWithIdentifier:@"4ImagesCell"];
      if (cell == nil) {
              cell = [[[ImageTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"4ImagesCell"] autorelease];
      }
      return cell;
  }
  </code></pre>
  
  <p>The console here "always" prints the following:</p>
  
  <pre><code>cellForRowAtIndexPath: &lt;NSIndexPath 0x5a4f2c0&gt; 2 indexes [0, 0]
  cellForRowAtIndexPath: &lt;NSIndexPath 0x5a4f2c0&gt; 2 indexes [0, 1]
  cellForRowAtIndexPath: &lt;NSIndexPath 0x5a4f2c0&gt; 2 indexes [0, 2]
  cellForRowAtIndexPath: &lt;NSIndexPath 0x5a4f2c0&gt; 2 indexes [0, 3]
  cellForRowAtIndexPath: &lt;NSIndexPath 0x5a4f2c0&gt; 2 indexes [0, 4]
  </code></pre>
  
  <p>No matter what the value returned by numberOfRowsInSection is, whether it is a Zero or a 100, the table always asks for 5 rows! I even tried returning a static number in numberOfRowsInSection instead of the current conditions, but it makes no difference for the actual number of cells!</p>
  
  <p>What drives me crazy is that the table does reach the numberOfRowsInSection method before going to cellForRowAtIndexPath! </p>
  
  <p>The only thing I can think of that maybe causing this is that this table controller is pushed from another UITableViewController, but the previous table's numberOfRowsInSection method is never checked while I'm in this table, I even tried to modify the number of rows in the parent table without any luck.</p>
  
  <p>If there is any kind of info missing please let me know. The project is quit complicated and I can't think of any other relevant info for this problem.</p>