title: 'NSInternalInconsistencyException', reason: 'attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update'
body: <p>Im pretty new at iOS programming, I'm trying to make this budget app. I want to add a instance class of my budget class to my tableview. But when I'm hitting the done button this error comes up. I've been searching the forum for an answer to my problem. </p>
  
  <p>So fare I've found Aby how has the same problem as I (http://stackoverflow.com/questions/11706254/nsinternalinconsistencyexception-reason-attempt-to-insert-row-0-into-section?answertab=active#tab-top) but I can't really get a clear answer/solution to my problem in that post.</p>
  
  <p>I'm quit sure I know why this error happens, but how do solve it I don't know :-( 
  Any who can help me solving this problem?</p>
  
  <p>I would like to post some pic of my code but stackoverflow will not allow me due to spam securing.</p>
  
  <p>AddBugdetViewController.m</p>
  
  <pre><code>(IBAction)done
  {
      [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
  
      Budget *budget = [[Budget alloc] init];
      budget.name = self.textField.text;
      budget.amount = [Budget convertStringToNSNumber:self.textField.text];
  
      [self.delegate addBudgetViewController:self didFinishAddingItem:budget];
  }
  </code></pre>
  
  <p>BudgetViewController.m</p>
  
  <pre><code>(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      return [self.budget.items count];
  }
  
  (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Budgets"];
  
      Budget *item = [self.budget.items objectAtIndex:indexPath.row];
  
      [self configureTextForCell:cell withChecklistItem:item];
  
      return cell;
  }
  
  - (void)addBudgetViewController:(AddBudgetViewController *)controller didFinishAddingItem:(Budget *)NewBudget
  {
      NSLog(@"Adding budget: %@", NewBudget.name);
      NSLog(@"Budget amount: %@", NewBudget.amount);
  
      [self.tableView beginUpdates];
  
      int newRowIndex = [self.budget.items count];
      [self.budget.items addObject:NewBudget];
  
      NSIndexPath *indexPath = [NSIndexPath indexPathForRow:newRowIndex inSection:0];
      NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
      [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];
  
      [self.tableView endUpdates];
  
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  </code></pre>
  
  <p>Please tell me if you need more information to track down the problem and solve it :-)</p>
  
  <p>Cheers Anders</p>