we are using core data for our online catalog and its working fine and app available in app store now I need to upgrade the core date with some of fields and attributes. It migrated to new one but old data already stored in the app are completely vanished. I tried various ways to retain it using this code
NSString *databaseFilePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"App_iOS.sqlite"];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:databaseFilePath error:NULL];
NSURL *storeUrl = [NSURL fileURLWithPath: databaseFilePath];
NSError *error = nil;
if( ![[self persistentStoreCoordinator] addPersistentStoreWithType:NSSQLiteStoreType configuration: nil URL:storeUrl options:nil error:&error])
{
[__managedObjectContext insertObjects];
}
else
{
[__managedObjectContext updatedObjects];
}
I am not get solution yet to retain the data in app. I searched in internet for this most of the face the same problem but I am not receive the good solution yet