Ich bin gerade dabei, eine Urlaubsjournal wie Anwendung zu entwickeln, die jeden Ort speichert, den Sie von seinem Typ besucht haben. Zum Beispiel sollte ein Restaurantname unter "Essen" -Abschnitt gespeichert werden. Ich habe es geschafft, mit Kerndaten zu arbeiten und die Tabelle ohne Probleme zu erstellen. Doch das Problem ist, wenn ich versuche, den Typ eines Ortes zu ändern (also Tableview Bedarf neu zu ordnen), würde ich eine Fehlermeldung erhalten:Reorder Fetch Ergebnisse Controller für UITableView
2009-07-22 21:04:58.150 HolidayTest[8662:20b] Serious application error. Exception was caught during Core Data change processing: *** -[NSCFArray removeObjectAtIndex:]: index (4) beyond bounds (4) with userInfo (null)
2009-07-22 21:04:58.151 HolidayTest[8662:20b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray removeObjectAtIndex:]: index (4) beyond bounds (4)'
Ich weiß, dass die Ergebnisse Controller holen Delegat die Tabelle aktualisiert hat. Das Problem ist jedoch, dass der Abrufcontroller seine eigenen Abschnitts- und Zeilendaten nicht aktualisiert hat. Der einfache Weg besteht darin, den Abrufergebnis-Controller anzuweisen, seine Daten erneut abzurufen, wenn der Benutzer seinen Typ ändert. Es ist jedoch keine effiziente Möglichkeit, die Daten zu verwalten.
Vielen Dank für Ihre Antwort TahoeWolverine. Hier ist der Code, wo ich den Typ eines Ortes ändere, wo der Benutzer eine Zeile in einer Tabellenansicht auswählt, um seinen Typ zu ändern.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath *selectionIndexPath = [NSIndexPath indexPathForRow:selected inSection:0];
UITableViewCell *checkedCell = [tableView cellForRowAtIndexPath:selectionIndexPath];
checkedCell.accessoryType = UITableViewCellAccessoryNone;
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
selected = indexPath.row;
NSManagedObject *aType = [siteType objectAtIndex:indexPath.row];
self.site.type = [aType valueForKey:@"name"];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.delegate TypeSelectionController:self didChangeType:YES];
}
dieser Code entspricht der Delegierten Ergebnisse Controller holen, die den folgenden Code läuft
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
[self.tableView beginUpdates];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {
UITableView *tableView = self.tableView;
switch(type)
{
case NSFetchedResultsChangeInsert:
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeDelete:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeUpdate:
[self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
break;
case NSFetchedResultsChangeMove:
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:newIndexPath.section] withRowAnimation:UITableViewRowAnimationFade];
break;
}
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id) <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
switch(type)
{
case NSFetchedResultsChangeInsert:
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeDelete:
[self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
break;
}
}
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
[self.tableView endUpdates];
}
dann werde ich das bekommen die Fehlermeldung .......
posten Sie bitte die Codeaufrufe, die Sie machen – TahoeWolverine