1

我有多个领域文件(每个用户一个登录到我的应用程序),我需要为文件系统中的每个领域文件运行迁移

      RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];

  config.schemaVersion = 1;
  config.migrationBlock = ^(RLMMigration *migration, uint64_t oldSchemaVersion) {

    if (oldSchemaVersion < 1) {
    //do the same changes for all file.realm in the filesystem 
    }
  };


  [RLMRealmConfiguration setDefaultConfiguration:config];

  [RLMRealm defaultRealm];

如何为每个文件系统数据库执行领域迁移,而不仅仅是默认领域文件?

4

1 回答 1

2

+[RLMRealm migrateRealm:]在配置指定的路径上执行 Realm 的迁移:

RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.schemaVersion = 1;
config.migrationBlock = ...;
config.path = @"path 1";
[RLMRealm migrateRealm:config];
config.path = @"path 2";
[RLMRealm migrateRealm:config];
于 2015-10-05T21:15:44.293 回答