Skip to content

NSMutableDictionary

NSMutableDictionary 是可变字典类型,用于构造与更新键值对集合。

预分配容量创建。

static dictionaryWithCapacity(numItems: number): NSMutableDictionary

Parameters:

NameTypeDescription
numItemsnumber初始容量。

Return Value:

  • NSMutableDictionary: 新字典。

使用 sharedKeySet 创建字典(用于大量相同 key 的字典以提升性能)。

static dictionaryWithSharedKeySet(sharedKeySet: any): NSMutableDictionary

为 keys 生成 sharedKeySet。

static sharedKeySetForKeys(keys: NSArray): any

注:NSMutableDictionary 的工厂方法在插件运行时的导出范围较小;请以本页底部的「头文件 API 清单」为准。

设置键值对。

setObjectForKey(anObject: any, aKey: any): void

Parameters:

NameTypeDescription
anObjectany值。
aKeyany键。

Return Value:

  • 无。

下标形式设置键值对。

setObjectForKeyedSubscript(obj: any, key: any): void

Parameters:

NameTypeDescription
objany值。
keyany键。

Return Value:

  • 无。

移除指定键的条目。

removeObjectForKey(aKey: any): void

Parameters:

NameTypeDescription
aKeyany键。

Return Value:

  • 无。

清空字典。

removeAllObjects(): void

Return Value:

  • 无。

将另一字典所有条目合并进来。

addEntriesFromDictionary(otherDictionary: NSDictionary): void

Parameters:

NameTypeDescription
otherDictionaryNSDictionary源字典。

Return Value:

  • 无。

用另一字典替换全部内容。

setDictionary(otherDictionary: NSDictionary): void

Parameters:

NameTypeDescription
otherDictionaryNSDictionary源字典。

Return Value:

  • 无。

移除给定键数组中的键对应条目。

removeObjectsForKeys(keyArray: NSArray): void

Parameters:

NameTypeDescription
keyArrayNSArray要移除的键数组。

Return Value:

  • 无。

objectForKey(key)allKeys()allValues()enumerateKeysAndObjectsUsingBlock(block) 等用法与 NSDictionary 一致。

头文件 API 清单

正在加载…

协议:,来源: