Realm-cocoa: Move/copy objects between realms?

Created on 27 Oct 2014  路  5Comments  路  Source: realm/realm-cocoa

Hi,

Is it possible to move/copy objects between realms?

Regards,

Raul Perez

Most helpful comment

I'm looking for this functionality but can't find this method - only create with a dictionary. Anyone knows if it's still possible to do this, and if yes how? (Using Swift).

All 5 comments

You can call -createInRealm:withObject: to create a copy of a persisted object in a second Realm.

Seems that this doesn't work on version 0.86.3.

Realm raise and exception that says that the object is already persisted on a Realm.

Regards

Calling -addObject: on objects from other Realms should fail, but calling -createInRealm:withObject: should work. We have tests for this starting here: https://github.com/realm/realm-cocoa/blob/master/Realm/Tests/RealmTests.mm#L191

Perhaps you are doing something that we are not testing? What methods/code is causing issues for you?

I'm looking for this functionality but can't find this method - only create with a dictionary. Anyone knows if it's still possible to do this, and if yes how? (Using Swift).

Was this page helpful?
0 / 5 - 0 ratings