NSMergeConflict para NSManagedObject con un solo ManagedObjectContext
Estoy trabajando con coreData, tengo una o muchas relaciones entre carpetas y archivos.
Estoy usando solo un MOC a través de mi aplicación. Solo lo estoy pasando a diferente
viewControllers, realizando operaciones como agregar, editar, eliminar y luego guardar.
Mi rootViewController usa NSfetchResultsController, creo carpetas usándolo, guardo y visualizo en mi tabla.
ahorrando lo hago de esta manera
NSError *error;
if (![self.managedObjectContext save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
luego, cada vez que selecciono una carpeta, abro un archivo ViewController, mientras se abre, paso el MOC al archivo VC de esta manera
FileViewController *file = [[FileViewController alloc] initWithNibName:@"FileViewController" bundle:nil];
file.managedObjectContext = self.managedObjectContext;
file.controller = self.controller;
luego creo un archivo dentro de FileVC y de nuevo lo guardo en FileVC, de esta manera
NSError *error;
if (![self.managedObjectContext save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
Al hacer esto, ¿estoy usando dos MOC o un solo MOC?
En mi appdelegate.m, también probé esto
self.rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
_navigationController = [[UINavigationController alloc] initWithRootViewController:self.rootViewController];
[self.managedObjectContext setMergePolicy:NSMergeByPropertyStoreTrumpMergePolicy];
self.rootViewController.managedObjectContext = self.managedObjectContext;
A veces, cuando agrego un archivo dentro de una carpeta, obtengo "NSMergeConflict for NSManagedObject"
Por favor ayuda
Saludos Ranjit.