I'm using Kotlin and Realm to write a data class
data class AuthToken(val register: Boolean,
val token: String,
val tokenSecret: String,
val user: AuthUser)
我必须将数据保存到数据库中,所以我使用Realm来保存它.但正如我们所知,如果我想将类保存到Realm,AuthToken
类必须扩展RealmObject
.
That's the problem, Kotlin says data classes can't extend classes. so I give up data class, just using a normal Kotlin class as a model then another question comes:
Kotlin class has no getter or setter. As we know Realm class have to set all the property private and write getter and setter.
Now i'm wondering how to solve the problem.