正在迁移,但仍在"RLMException"上崩溃,原因:“需要迁移 [英] Migrating, but still getting crash on 'RLMException', reason: 'Migration is required
本文介绍了正在迁移,但仍在"RLMException"上崩溃,原因:“需要迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Realm, 1th thing
{
RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.schemaVersion = 2;
config.migrationBlock = ^(RLMMigration *migration, uint64_t oldSchemaVersion) {
};
config.objectClasses = @[[User class], [UsersMenuItem class]];
[RLMRealm migrateRealm:config];
}
...
}
我确实向用户对象添加了一个属性,文档表示新领域应该自动迁移,但是我崩溃了
I did add a property to the user object, the docu says the new realm should automigrate, but i get a crash
*** Terminating app due to uncaught exception 'RLMException', reason: 'Migration is required for object type 'User' due to the following errors:
- Property 'realtedMenuItems' has been added to latest object model.'
*** First throw call stack:
(0x1838ad900 0x182f1bf80 0x10015db3c 0x10014aa60 0x100149a70 0x100116500 0x1000a6488 0x1000f1664 0x1885a00c0 0x18859fcc4 0x100039568 0x188615704 0x188844130 0x1888484b8 0x1888455c0 0x184e63790 0x184e63b10 0x183864efc 0x183864990 0x183862690 0x183791680 0x18860e580 0x188608d90 0x1000b7430 0x1833328b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
版本:0.95
注意:当我更新到0.96时,我会得到
Note: When i updated to 0.96 i get
*** Terminating app due to uncaught exception 'RLMException', reason: 'Provided schema version 0 is less than last set version 3.'
*** First throw call stack:
推荐答案
看起来像添加
[RLMRealmConfiguration setDefaultConfiguration:config];
解决了该问题,尽管不确定原因
solved the issue, although not sure why
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Realm
{
RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.schemaVersion = 4;
config.migrationBlock = ^(RLMMigration *migration, uint64_t oldSchemaVersion) {
};
NSError * error = [RLMRealm migrateRealm:config];
if (error) {
NSLog(@"Error migrating realm %@", error);
}
[RLMRealmConfiguration setDefaultConfiguration:config];
}
这篇关于正在迁移,但仍在"RLMException"上崩溃,原因:“需要迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文