获取可空 列表

摘要 乐趣 <t : Any> getNullableValueList(propertyName : string , clazz : KClass < T >): RealmList<t?>

RealmList 形式返回属性名称引用的可空元素列表。

class参数必须是属性的RealmStorageTypeKClass

以下代码片段概述了可用于不同列表类型的不同函数:

// Retrieve a list of nullable ints from a 'nullableIntList' property
dynamicRealmObject.getNullableValueList("nullableIntList", Int::class)

// Retrieve a list of non-nullable ints from a 'intList' property
dynamicRealmObject.getValueList("intList", Int::class)

// Retrieve a list of objects from an `objectList' property
// Object lists are ALWAYS non-nullable
dynamicRealmObject.getObjectList("objectList", DynamicRealmObject::class)

返回

引用的RealmList

参数

属性 名称

要为其检索列表的列表属性的名称。

clazz

列表元素类型的 Kotlin 类。

t

列表元素类型的类型。

抛出异常

如果类不包含具有特定名称的字段、如果尝试检索非列表属性的值或者clazz与属性的RealmStorageType.kClass不匹配。