Is it possible to manage data stored amongst several files?
Let's say I have several files data1.realm
, data2.realm
, data3.realm
, etc. containing objects with the same model. Is it possible to get a unique RLMRealm
instance that will access the datas of all these files?
If not, what is the best way to handle this situation? Migration?
It's definitely possible to manage data stored amongst separate Realms, but it wouldn't be automatic. You would need to manage access to this data in your own app's logic.
RLMRealm
instances themselves represent a single file on disk and cannot be dynamically created to reference combinations of other Realms. Once anRLMObject
has been added to a parentRLMRealm
, it cannot be moved/backed to anotherRLMRealm
representing a different file.It most likely depends on your specific use-cases, but the simplest solution would be to simply query for your objects in separate
RLMRealm
instances for each file, and placing the resultingRLMResults
objects from each one in anNSArray
.While data can't be directly shared between Realms, you could use globally unique primary keys (For example
NSUUID
) to indicate relationships between objects in different Realms.If you need, it's also possible to create Realmless copies of
RLMObject
s if you do end up wanting to move objects between Realms: