NoTBleeD
NoTBleeD

Reputation: 71

Realm does not save data

I come here because I have an issue with Realm.

My Realm is empty, I have my Object "User", which is completed (id, name, etc...), and when I write it into the Realm, everything is good.

But when I request my object again, it exists, but is empty, no data... Do you know what's wrong?

Here is a small example of my code :

println("id: " + currentUser.id) // "id: 2"
Realm().write
    {
        println("id: " + currentUser.id) // "id: 2"
        Realm().add(currentUser)
}
var user = Realm().objects(User).first!
println("id: " + user.id) // "id: "

EDIT: I checked my database with RealmBrowser, and every fields are full, with the correct data... So why does my query fail?

Upvotes: 1

Views: 2383

Answers (1)

NoTBleeD
NoTBleeD

Reputation: 71

I found my mistake, i accidentally forgot the "dynamic" modifier in front of every variables in my model "User".

Upvotes: 4

Related Questions