Custom class types permitted?


#1

I recently tried something like this:

open class Prize : RealmObject() {
    @PrimaryKey
    var prizeId: String = "" 
    var description : String = ""
    var cashValue : Float = 0.0f
    var raffleDateAndTime: Date = Date()

In another RealmObject I tried to use prize. Like this…

open class Event : RealmObject() {
    @PrimaryKey
    var eventId: String = "" //Needs to be unique given it's a primary key
    var location: String = ""
    var description : String = ""
    var eventStart: Date = Date()
    var eventEnd: Date = Date()
    var prizes : List<Prize> = mutableListOf<Prize>()

When I go to run it, I get “these types will not undergo annotation processing”

Is there a way to get Realm to understand custom build classes like Prize?


#2

Here is the solution…use RealmList

So:

var prizes : List = mutableListOf()

becomes

var prizes : RealmList = RealmList()