I have some strange problems with Core Data in iOS that I cannot reproduce, this happens from time to time to some users who report this. The error I get from iOS crash reports:
CoreData: - [NSPsistentStoreCoordinator _coordinator_you_never_successfully_opened_the_database_so_saving_back_to_it_is_kinda_hard:] + 56
Here is a screenshot (product name not specified):

It is tough that I do not get any search results for this error. Here is my (relevant) code:
preservation:
-(void)save
{
if(!self.horecaMOC.hasChanges)return;
NSError *error;
[self.horecaMOC save:&error];
if(error)
{
NSLog(@"save error %@",error.localizedDescription);
}
}
MOC:
-(NSManagedObjectContext*)horecaMOC
{
if(!_horecaMOC)
{
NSPersistentStoreCoordinator *coordinator = self.horecaPSC;
if (coordinator != nil) {
_horecaMOC = [[NSManagedObjectContext alloc] init];
[_horecaMOC setPersistentStoreCoordinator:coordinator];
}
}
return _horecaMOC;
}
PSC:
-(NSPersistentStoreCoordinator*)horecaPSC
{
if(!_horecaPSC)
{
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"horeca.sqlite"];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
nil];
NSError *error = nil;
_horecaPSC = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.horecaMOM];
if (![_horecaPSC addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
return _horecaPSC;
}
MUM:
-(NSManagedObjectModel*)horecaMOM
{
if(!_horecaMOM)
{
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"poi" withExtension:@"momd"];
_horecaMOM = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
}
return _horecaMOM;
}
, , 99% , , . , , . PSC nil? ? , , MOC 1 , , , ?
!