Realm Migration — Renaming a class and migrating nested objects

Photo by Miles Storey on Unsplash

Introduction

Realm objects structure before the migration
Realm objects structure at the end of the migration

Renaming a class

“Renaming” a Realm class and migrating the user’s data

Migrate a complex Realm object included in another Realm object

First migration step: create the new object and migrate attributes
Recovery of the Sport object from the User object in type“Any”
Sport object data from the User object
Sport object from User object casted to Realm object
Compilation error when we try to access to the Sport ID of the user like a key value dictionary
One solution to get the ID of the Sport object from the User object
The final solution

What’s next?

--

--

This is Lunabee Studio’s account, on which we share content on various topics, including of course Mobile Apps’ creation.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lunabee Studio Dev

This is Lunabee Studio’s account, on which we share content on various topics, including of course Mobile Apps’ creation.