title: How do I insert new cells in a UITableView?
body: <p>I am trying to add a row to a tableview using</p>
  
  <pre><code>NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
  [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
  </code></pre>
  
  <p>It throws an exception where I call insertRowsAtIndexPaths:withRowAnimation:, which says </p>
  
  <pre><code>Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
  </code></pre>
  
  <p>It is returning the correct number of rows and sections, but it never makes it to cellForRowAtIndexPath before throwing the exception.  I am doing this with a storyboard also and I have the tableView set to have static cells because the majority of the tableView does in fact have static cells.  I really don't want to switch over to dynamic prototypes because then I can't have IBOutlets and IBActions, which I am using, and I would have to essentially start over with respect to the layout of the cells.  Is there any way for me to get rid of this exception without changing my tableView to have dynamic prototype cells?</p>
  
  <p><em><strong>Edit</em></strong></p>
  
  <p>The line right before what I posted is</p>
  
  <pre><code>[itemsInCurrentPurchase insertObject:itemName atIndex:0];
  </code></pre>
  
  <p>which is supposed to update the array.  I am using</p>
  
  <pre><code>[itemsInCurrentPurchase count]
  </code></pre>
  
  <p>for my number of rows in section and it is returning the correct number after the update.  The problem is that the cellForRowAtIndexPath method is not even being reached.  During the update is there anything else that gets called between the number of rows and the cell type that could be causing this error?</p>