create Embedded Object
inline fun <T : RealmModel> Realm.createEmbeddedObject(parentObject: RealmModel, parentProperty: String): T
Content copied to clipboard
Instantiates and adds a new embedded object to the Realm.
This method should only be used to create objects of types marked as embedded.
Return
the newly created embedded object.
Parameters
T
the Class of the object to create. It must be marked with @RealmClass(embedded = true)
.
parentObject
The parent object which should hold a reference to the embedded object. If the parent property is a list the embedded object will be added to the end of that list.
parentProperty
the property in the parent class which holds the reference.
Throws
if clazz
is not an embedded class or if the property in the parent class cannot hold objects of the appropriate type.