NSDictionary(GCKAdditions) 类别
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
一个类别,向 NSDictionary 添加了一些便捷方法,用于安全地查找各种类型的值。
这些方法对于获取和设置 JSON 数据对象的字段特别有用。
- (nullable NSString *) gck_stringForKey: |
|
(NSString *) |
key |
withDefaultValue: |
|
(nullable NSString *) |
defaultValue |
|
|
| |
查找具有指定后备值的键的 NSString 值。
- Parameters
-
key | The key. |
defaultValue | The default value to return if the key is not found or if its value is not an NSString. |
- 返回
- 键的值(如果找到了键,且为 NSString);否则为默认值。
- (nullable NSString *) gck_stringForKey: |
|
(NSString *) |
key |
|
- (NSInteger) gck_integerForKey: |
|
(NSString *) |
key |
withDefaultValue: |
|
(NSInteger) |
defaultValue |
|
|
| |
查找具有指定后备值的键的 NSInteger 值。
- Parameters
-
key | The key. |
defaultValue | The default value to return if the key is not found or if its value is not an NSNumber. |
- 返回
- 如果找到了键的值,则为 NSNumber;否则为默认值。
- (NSUInteger) gck_uintegerForKey: |
|
(NSString *) |
key |
withDefaultValue: |
|
(NSUInteger) |
defaultValue |
|
|
| |
查找具有指定后备值的键的 NSUInteger 值。
- Parameters
-
key | The key. |
defaultValue | The default value to return if the key is not found or if its value is not an NSNumber. |
- 返回
- 如果找到了键的值,则为 NSNumber;否则为默认值。
- (NSInteger) gck_integerForKey: |
|
(NSString *) |
key |
|
- (NSUInteger) gck_uintegerForKey: |
|
(NSString *) |
key |
|
- (double) gck_doubleForKey: |
|
(NSString *) |
key |
withDefaultValue: |
|
(double) |
defaultValue |
|
|
| |
查找具有指定后备值的键的 double 值。
- Parameters
-
key | The key. |
defaultValue | The default value to return if the key is not found or if its value is not an NSNumber. |
- 返回
- 如果找到了键的值,则为 NSNumber;否则为默认值。
- (double) gck_doubleForKey: |
|
(NSString *) |
key |
|
查找回退值为 0.0
的键的 double 值。
- Parameters
-
- 返回
- 键的值(如果找到了键,且为 NSNumber);否则为
0.0
。
- (BOOL) gck_boolForKey: |
|
(NSString *) |
key |
withDefaultValue: |
|
(BOOL) |
defaultValue |
|
|
| |
查找具有指定后备值的键的 BOOL 值。
- Parameters
-
key | The key. |
defaultValue | The default value to return if the key is not found or if its value is not an NSNumber. |
- 返回
- 如果找到了键的值,则为 NSNumber;否则为默认值。
- (BOOL) gck_boolForKey: |
|
(NSString *) |
key |
|
查找回退值为 NO
的键的 BOOL 值。
- Parameters
-
- 返回
- 键的值(如果找到了键,且为 NSNumber);否则为
NO
。
- (nullable NSDictionary *) gck_dictionaryForKey: |
|
(NSString *) |
key |
|
- (nullable NSArray *) gck_arrayForKey: |
|
(NSString *) |
key |
|
查找回退值为 nil
的键的 NSArray 值。
- Parameters
-
- 返回
- 键的值(如果找到了键,且为 NSArray),否则为
nil
。
- (nullable NSURL *) gck_urlForKey: |
|
(NSString *) |
key |
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2023-12-01。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"没有我需要的信息"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"太复杂/步骤太多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"内容需要更新"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/代码问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]