我们正在使用核心数据作为我们的在线目录,并且其工作正常且应用商店中可用的应用现在我需要升级核心日期,字段和属性。它已经迁移到新的,但已经存储在应用程序中的旧数据完全消失。我试过各种方法来保留它使用此代码核心数据迁移xcode 4.2不会更新应用商店中已有应用的数据
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];
}
我还没有得到解决方案,但仍然保留在应用程序中的数据。我在互联网上搜索了这个大部分的面对同样的问题,但我还没有收到良好的解决方案,但尚未
[link] http://stackoverflow.com/questions/1018155/what-do-i-have-to-do-to-get-core-data-to-automatically-migrate-models这个答案非常有帮助实现核心数据更新。感谢所有! – 2011-12-29 11:36:26