ios修改了coredata数据结构后,更新安装会闪退
来源:互联网 发布:装修风格效果图软件 编辑:程序博客网 时间:2024/06/05 14:53
(转)iOS App升级安装 - CoreData数据库升级
如果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.重新编译下程序
0 0
- ios修改了coredata数据结构后,更新安装会闪退
- iOS 添加了Today Widget后修改BundleID后报错
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- IOS CoreData
- iOS CoreData
- iOS-CoreData
- iOS CoreData
- iOS CoreData
- iOS--CoreData
- iOS coreData
- iOS coreData
- IOS CoreData
- 【拓扑排序】 Codeforces Round #290 (Div. 1) A Fox And Names
- 一个项目经理的个人体会、经验总结
- 进程、控制终端、会话、守护进程
- C++的static静态函数
- VMWare Image Clone Problem: eth0 Renamed As eth1
- ios修改了coredata数据结构后,更新安装会闪退
- 关于大型网站技术演进的思考(一)--存储的瓶颈(1)
- 下拉框应用
- linux 进程高cpu问题分析
- Oracle数据库分区存储
- IE动态加载js
- jacob调用Excel中的宏
- 【android】Sqlite中使用SQL与其他数据库的区别
- oc中alloc和init等基本注意和使用