获取ValueSet

摘要 乐趣 <t : Any> getValueSet(propertyName : string , clazz : KClass < T >): RealmSet<t>

RealmSet的形式返回属性名称引用的非空值元素集。

class参数必须是属性的RealmStorageTypeKClass

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

// Retrieve a set of nullable ints from a 'nullableIntSet' property
dynamicRealmObject.getNullableValueSet("nullableIntSet", Int::class)

// Retrieve a set of non-nullable ints from a 'intSet' property
dynamicRealmObject.getValueSet("intSet", Int::class)

// Retrieve a set of objects from an `objectSet' property
// Object sets are ALWAYS non-nullable
dynamicRealmObject.getObjectSet("objectSet", DynamicRealmObject::class)

返回

引用的RealmSet

参数

属性 名称

要为其检索集合的集合属性的名称。

clazz

set 元素类型的 Kotlin 类。

t

设置元素类型的类型。

抛出异常

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