I have a superclass called Thing (I know it's not specific) that inherits from Object:
class Thing: Object {
dynamic var title: String = ""
var parents: [Thing] {
return linkingObjects(Thing.self, forProperty: "children")
}
let children = List<Thing>()
}
and two subclasses of that called Task and Thought.
However, when I do
someThing.children.append(Task())
it throws "Object type is incorrect."
What am I doing wrong? Does realm not allow subclasses in lists of superclasses because that doesn't make much sense.
Currently, Realm's inheritance mapping doesn't support yet polymorphism. You would need either dedicated lists with a concrete subclass as generic parameter or a whole different approach of inheritance mapping.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With