获取对象 字典

RealmDictionary的形式返回属性名称引用的对象的字典。

class参数必须是属性的 RealmStorageType 的KClass

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

// Retrieve a dictionary of nullable ints from a 'nullableIntDictionary' property
dynamicRealmObject.getNullableValueDictionary("nullableIntDictionary", Int::class)

// Retrieve a dictionary of non-nullable ints from a 'intDictionary' property
dynamicRealmObject.getValueDictionary("intDictionary", Int::class)

// Retrieve a dictionary of objects from an `objectDictionary' property
// Object dictionaries are ALWAYS nullable
dynamicRealmObject.getObjectDictionary("objectDictionary", DynamicRealmObject::class)

返回

引用的RealmDictionary

参数

属性 名称

要为其检索字典的字典属性的名称。

抛出异常

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