簡體   English   中英

Realm,Object已由另一個Realm管理

[英]Realm , Object is already managed by another Realm

  1. 使用領域來保存數據。
  2. 配置領域使用defaultconfig。
  3. 然后,我addOrUpdate一些RLMModels
  4. 這是成功的。
  5. 我更改了配置使用

     RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration]; config.fileURL = [[[config.fileURL URLByDeletingLastPathComponent] URLByAppendingPathComponent:@"myname"] URLByAppendingPathExtension:@"realm"]; [RLMRealmConfiguration setDefaultConfiguration:config]; 
  6. addOrUpdate相同的RLMModels

  7. 控制台打印錯誤:

     2017-11-09 10:50:18.293801+0800 LNLibBase_Example[96588:8779968] *** Terminating app due to uncaught exception 'RLMException', reason: 'Object is already managed by another Realm. Use create instead to copy it into this Realm.' 

正如錯誤消息所述,已經由Realm管理的對象無法添加到其他Realm。 你可以做的是使用+createInRealm:withValue:在不同的Realm中創建它的副本

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM