How can I easily duplicate/copy an existing realm object

realm, swift

Solution

In my case i just wanted to create an object and not persist it. so `segiddins`'s solution didn't work for me.

Swift 3

To create a clone of user object in `swift` just use

`let newUser = User(value: oldUser)`;

The new user object is not persisted.

Problem

I have a Realm Object which has several relationships, anyone has a good code snippet that generalizes a copy method, to create a duplicate in the database.

Original source