星空网 > 软件开发 > 操作系统

CoreData数据库迁移的操作

CoreData数据库迁移操作步骤,操作是基于Xcode7.

 

1.添加新的数据库.选中当前数据库版本:Editor->Add Model Verson,创建一个新的数据库版本.

2.Command + N,创建一个映射模型.iOS->CoreData->Mapping Model->Next,选择旧的数据库版本->Next,选择新的数据库版本->Create.

3.选中一个数据库,右侧工具栏第一个标签->ModelVerson->current,选择最新的数据库版本.

4.选择最新的数据库创建新的实体类.如图:

CoreData数据库迁移的操作images/loading.gif' data-original="http://images2015.cnblogs.com/blog/501477/201603/501477-20160331162745019-1233830613.png" />

5.在AppDelegate.m文件中找到方法:- (NSPersistentStoreCoordinator *)persistentStoreCoordinator;,在方法的实现中给options添加字典:@{NSInferMappingModelAutomaticallyOption:@(YES), NSMigratePersistentStoresAutomaticallyOption:@(YES)}.如下图:

CoreData数据库迁移的操作

经过上面的过程,即可完成数据库迁移.

 




原标题:CoreData数据库迁移的操作

关键词:数据库

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

中美海运fba:https://www.goluckyvip.com/tag/49344.html
中美航线:https://www.goluckyvip.com/tag/49345.html
中美商贸联委会:https://www.goluckyvip.com/tag/49346.html
中美专线:https://www.goluckyvip.com/tag/49347.html
中蒙铁路:https://www.goluckyvip.com/tag/49348.html
中缅专线:https://www.goluckyvip.com/tag/49349.html
2022世界杯门票如何买?:https://www.vstour.cn/a/363182.html
沈阳到本溪的距离有多远?(详细路线及交通方式):https://www.vstour.cn/a/363183.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流