iOS App升级安装 - CoreData数据库升级
来源:互联网 发布:php socket编程 断开 编辑:程序博客网 时间:2024/05/18 05:32
如果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");
- }
5.重新编译下程序。
转载:http://blog.csdn.net/wang9834664/article/details/8203177
0 0
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS App升级安装 - CoreData数据库升级
- iOS 版本迭代 App升级安装 CoreData数据库升级
- CoreData(数据库升级 )版本迁移-iOS App升级安装
- CoreData(数据库升级 )版本迁移-iOS App升级安装
- IOS APP 升级安装-coredata 的迁移,升级
- coredata 数据库升级
- iOS APP新版本升级数据库
- CoreData升级
- ios开发 升级App
- ios升级app
- iOS APP升级版本
- iOS 升级程序中已有的CoreData
- 监听网络状态的改变
- 图论五百题
- spring:<context:property-placeholder location="classpath:application.properties" />
- C++ Primer 学习笔记14 顺序容器
- activemq中的消费者生成及消息处理
- iOS App升级安装 - CoreData数据库升级
- CXF学习笔记(2)-HelloWorld!-客户端调用 .
- HDU1016.....dfs和&&的短路作用
- L1、L2 损失、正则
- 基于XML的用户界面标记语言-XUL和XAML
- mybaits3.2.8 别名包扫描通配符
- crontab定时任务中文乱码问题 -db2定时备份 -db2手动备份正常,定时乱码
- HAproxy with session sticky and HA
- 第十五周项目三在OJ上玩指针3