I am checking my app with iOS9.
A problem happens when I try to reset the database.
See the below code: (Its in AppDelegate)
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if(persistentStoreCoordinator == nil)
{
....
....
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
[persistentStoreCoordinator lock];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
{
}
[persistentStoreCoordinator unlock];
}
return persistentStoreCoordinator;
}
Here, the options are..
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,nil];
This code works fine with iOS8 and below. But when I run it with iOS9, the following exception happens.
CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///var/mobile/Containers/Data/Application/…..sqlite options:{ NSInferMappingModelAutomaticallyOption = 1; NSMigratePersistentStoresAutomaticallyOption = 1; } ... returned error Error Domain=NSCocoaErrorDomain Code=522 "(null)" UserInfo={NSUnderlyingException=I/O error for database at /var/mobile/Containers/Data/Application/….sqlite. SQLite error code:522, 'not an error', NSSQLiteErrorDomain=522} with userInfo dictionary { NSSQLiteErrorDomain = 522; NSUnderlyingException = "I/O error for database at /var/mobile/Containers/Data/Application/….*.sqlite. SQLite error code:522, 'not an error'"; }
But if I add the key-value pair as "journal_mode" = "MEMORY" in my existing "options" dictionary, this error was not happening.
Question:
What does "journal_mode" means in options dictionary? Is it the real problem in my case?