NSInternalInconsistencyException tout en ajoutant de la ligne de UITableView

J'ai de la difficulté avec l'ajout de nouvelle ligne à mon UITableView. J'ai lu sur des questions similaires sur stackoverflow, ai googlé, ... ne m'a pas aidé.

J'ai vide NSMutableArray *dataForList avec les données de UITableView. Après avoir cliqué sur un écran, je veux ajouter une nouvelle ligne. Cette erreur indique:

* Résiliation d'application en raison de uncaught exception 'NSInternalInconsistencyException', la raison: "tentative d'insérer la ligne 0 dans la section 0, mais il y a seulement 0 lignes dans la section 0, après la mise à jour'

Code:

NSArray *insertIndexPaths = [NSArray arrayWithObject: 
                             [NSIndexPath indexPathForRow:
                              [self.dataForList count] //is zero now
                              inSection:0]];

[self.dataForList addObject:newRow];
//[self.dataForList count] is 1 now

[self.unsignedTableView beginUpdates];
[self.unsignedTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationNone];
[self.unsignedTableView endUpdates]; //on this line error ocours

Ce qui me manque?

Tous UITableView méthodes

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *) indexPath {}

- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section {
return [self.mainController.dataForList count];
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *) indexPath{
return 38.0f;
}

- (UITableViewCell *) tableView: (UITableView *) tableView
      cellForRowAtIndexPath: (NSIndexPath *) indexPath {
//call render method in view, it works fain
return [self.signUpToTestView renderUnsignedCell:tableView cellForRowAtIndexPath:indexPath];
}
Cela peut être utile: stackoverflow.com/questions/1470898/...
Votre dataForList tableau, ce qui je suppose est la source de données pour votre vue de la table, est en décalage avec l'état de l'affichage de la table.
Oui, je le pense aussi, mais je ne sais pas, où suis-je makeing mystake.
Pourriez-vous montrer l'autre UITableView délégué méthodes? Notamment, j'imagine que le problème est dans la numberOfRowsForSection.
J'ai ajouté à ma question.

OriginalL'auteur kraag22 | 2012-04-04