Core数据更改属性从Integer 16到Integer 32 [英] Core Data change property from Integer 16 to Integer 32

查看:256
本文介绍了Core数据更改属性从Integer 16到Integer 32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常严重的问题。应用程序是活的,但不幸的是它在iOS 5上失败了,我需要发布更新。

I'm having a very serious problem. The application is live, but unfortunately it's fails on iOS 5, and I need to post an update.

事实是少数实体的ID列是Integer 16,但我需要改为Integer 32。

The thing is the ID column of few entities is in Integer 16, but I need to be changed to Integer 32.

这显然是我的错误,模型是很久以前创建的,它只被重复使用。令人惊讶的是(现在)在iOS 4,Core Data中的Integer 16可以容易地保持数字大到500 000(错误?),但它不工作,现在 - 它给我无效的数字。

It was clearly my mistake, the model was created very long time ago, and it was only being reused. To my surprise (now) on iOS 4, Integer 16 in Core Data could easily keep number as big as 500 000 (bug?), but it doesn't work like that now - it gives me invalid numbers.

应用程序是现场的,它的成功,Core Data也用于保持用户的分数,成就等,我不想删除,强制他们重新安装应用程序。什么是最好的方法,只是改变大约十个属性在不同的实体从整数16到整数32?

Application is live, has it success and Core Data is also used to keep the users scores, achievements and so on, what I don't want to remove, forcing them to reinstall the application. What is the best approach to simply change about ten of properties in different entities from Integer 16 to Integer 32?

当然,我知道这些属性的名称和实体。

Of course I know the names and entities for those properties.

如果我只是更改类型列那些属性在xcdatamodeld文件中,它将为新用户工作,但现有用户,在其Documents文件夹中已经有sqlite文件。我相信我需要改变持久性存储协调器以某种方式。

If I just change the Type column for those properties in the xcdatamodeld file it will work, for new user, but what about existing users, that already have sqlite file in their Documents folder. I believe I need to change the persistent store coordinator somehow.

还有你对性能有什么,有大约10个属性,消息从16更改为

And also what do you thing about the performance, there are about 10 properties that news to be changed from 16 to 32, but Core Data have in usual cases more than 100 000 objects inside.

推荐答案

在您的 NSPersistentStore 中开启 NSMigratePersistentStoresAutomaticallyOption'和'NSInferMappingModelAutomaticallyOption ,然后建立第二个版本你的模型的变化。只有整数更改才能保持迁移简单。

Turn on NSMigratePersistentStoresAutomaticallyOption' and 'NSInferMappingModelAutomaticallyOption in your NSPersistentStore and then create a second version of your model with the changes. Only do the integer changes to keep the migration simple. That will allow users who install your upgrade to migrate from the broken model to the corrected model.

注意:此必须是自动迁移;使用映射模型的手动迁移将无法运行。

NOTE: This must be an automatic migration; a manual migration with a mapping model will not work.

这篇关于Core数据更改属性从Integer 16到Integer 32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆