NSMutableDictionary
NSMutableDictionary 是可变字典类型,用于构造与更新键值对集合。
类成员 (Class members)
Section titled “类成员 (Class members)”dictionaryWithCapacity
Section titled “dictionaryWithCapacity”预分配容量创建。
static dictionaryWithCapacity(numItems: number): NSMutableDictionaryParameters:
| Name | Type | Description |
|---|---|---|
numItems | number | 初始容量。 |
Return Value:
NSMutableDictionary: 新字典。
dictionaryWithSharedKeySet
Section titled “dictionaryWithSharedKeySet”使用 sharedKeySet 创建字典(用于大量相同 key 的字典以提升性能)。
static dictionaryWithSharedKeySet(sharedKeySet: any): NSMutableDictionarysharedKeySetForKeys
Section titled “sharedKeySetForKeys”为 keys 生成 sharedKeySet。
static sharedKeySetForKeys(keys: NSArray): any注:
NSMutableDictionary的工厂方法在插件运行时的导出范围较小;请以本页底部的「头文件 API 清单」为准。
实例成员 (Instance members)
Section titled “实例成员 (Instance members)”setObjectForKey
Section titled “setObjectForKey”设置键值对。
setObjectForKey(anObject: any, aKey: any): voidParameters:
| Name | Type | Description |
|---|---|---|
anObject | any | 值。 |
aKey | any | 键。 |
Return Value:
- 无。
setObjectForKeyedSubscript
Section titled “setObjectForKeyedSubscript”下标形式设置键值对。
setObjectForKeyedSubscript(obj: any, key: any): voidParameters:
| Name | Type | Description |
|---|---|---|
obj | any | 值。 |
key | any | 键。 |
Return Value:
- 无。
removeObjectForKey
Section titled “removeObjectForKey”移除指定键的条目。
removeObjectForKey(aKey: any): voidParameters:
| Name | Type | Description |
|---|---|---|
aKey | any | 键。 |
Return Value:
- 无。
removeAllObjects
Section titled “removeAllObjects”清空字典。
removeAllObjects(): voidReturn Value:
- 无。
addEntriesFromDictionary
Section titled “addEntriesFromDictionary”将另一字典所有条目合并进来。
addEntriesFromDictionary(otherDictionary: NSDictionary): voidParameters:
| Name | Type | Description |
|---|---|---|
otherDictionary | NSDictionary | 源字典。 |
Return Value:
- 无。
setDictionary
Section titled “setDictionary”用另一字典替换全部内容。
setDictionary(otherDictionary: NSDictionary): voidParameters:
| Name | Type | Description |
|---|---|---|
otherDictionary | NSDictionary | 源字典。 |
Return Value:
- 无。
removeObjectsForKeys
Section titled “removeObjectsForKeys”移除给定键数组中的键对应条目。
removeObjectsForKeys(keyArray: NSArray): voidParameters:
| Name | Type | Description |
|---|---|---|
keyArray | NSArray | 要移除的键数组。 |
Return Value:
- 无。
访问与枚举(同 NSDictionary)
Section titled “访问与枚举(同 NSDictionary)”objectForKey(key)、allKeys()、allValues()、enumerateKeysAndObjectsUsingBlock(block) 等用法与 NSDictionary 一致。