Core Data Reset [duplicado]

Esta pregunta ya tiene una respuesta aquí:

Restablecer una tienda persistente CoreData 7 respuestas

Estoy trabajando para restablecer mis datos en coreData, a continuación se muestra mi código para restablecer mis datos en CoreData

- (void) resetApplicationModel
{   
   __managedObjectContext = nil;
   __managedObjectModel = nil;
   __persistentStoreCoordinator = nil;
   _allPageViewController.controller = nil;


    NSError *error;
    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"abc.sqlite"];


    if ([[self.managedObjectContext persistentStoreCoordinator] removePersistentStore:[[[self.managedObjectContext persistentStoreCoordinator] persistentStores] lastObject] error:&error])
    {
        // remove the file containing the data
        if([[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error])
        {        

            //recreate the store like in the appDelegate method
            if([self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error] == nil)
            {
                NSLog( @"could not create new persistent store at %@ - %@", [storeURL absoluteString], [error localizedDescription]);
            }
        }
        else
        {
            NSLog( @"could not remove the store URL at %@ - %@", [storeURL absoluteString], [error localizedDescription]);
        }

    }
    else
    {
        NSLog( @"could not remove persistent store - %@", [error localizedDescription]);
    }
}

Este código funciona correctamente, todos mis datos en la tabla se eliminan. Ahora, cuando trato de agregar nuevamente, aparece este error

CoreData: error: Serious application error.  An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:.  attempt to insert row 3 into section 0, but there are only 0 rows in section 0 after the update with userInfo (null)

Intenté depurar este problema y llegué a saber que mi base de datos está vacía. Pero no entiendo por qué. si ejecuto la aplicación sin restablecer, todo funciona bien.

Asi es que, por favor ayudame

Aquí está mi código sobre los delegados de FRC

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{

        [m_tableView beginUpdates];

}

- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
           atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{

    if (!m_userDrivenModelChange)
    {        
        switch(type) 
        {
            case NSFetchedResultsChangeInsert:
                [m_tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
                break;

            case NSFetchedResultsChangeDelete:
                [m_tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
                break;       
        }
    }
}

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath
{      
        switch(type) {
            case NSFetchedResultsChangeInsert:
                [m_tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationLeft];
                break;

            case NSFetchedResultsChangeDelete:
                [m_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;

            case NSFetchedResultsChangeMove:
                [m_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                [m_tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationFade];
                break;
        }    
}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{

        [m_tableView endUpdates];
}

App está fallando en la línea [m_tableView endUpdates].

Regards Ranjit

Respuestas a la pregunta(1)

Su respuesta a la pregunta