旅游网站开发周期,网站建设开发工具,画册设计流程步骤,wordpress博客注册如果iOS App 使用到CoreData#xff0c;并且在上一个版本上有数据库更新#xff08;新增表、字段等操作#xff09;#xff0c;那在覆盖安装程序时就要进行CoreData数据库的迁移#xff0c;具体操作如下#xff1a; 1.选中你的mydata.xcdatamodeld文件#xff0c;选择菜… 如果iOS App 使用到CoreData并且在上一个版本上有数据库更新新增表、字段等操作那在覆盖安装程序时就要进行CoreData数据库的迁移具体操作如下 1.选中你的mydata.xcdatamodeld文件选择菜单editor-Add Model Version 比如取名mydata2.xcdatamodel 2.设置当前版本 选择上级mydata.xcdatamodeld 在inspector中的Versioned Core Data Model选择Current模版为mydata2 3.修改新数据模型mydata2在新的文件上添加字段及表 4.删除原来的类文件重新生成下类。这一步没有做 在appdelegate中 NSDictionary *optionsDictionary [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:optionsDictionary error:error]) { NSLog(failed to add persistent store with type to persistent store coordinator); } 添加 *optionsDictionary原来options:nil 改成options:optionsDictionary 5.重新编译下程序 转载于:https://www.cnblogs.com/Free-Thinker/p/7094713.html