NSDictionary(GCKAdditions) 类别

NSDictionary(GCKAdditions) 类别参考

概览

一个类别,向 NSDictionary 添加了一些便捷方法,用于安全地查找各种类型的值。

这些方法对于获取和设置 JSON 数据对象的字段特别有用。

实例方法摘要

(nullable NSString *) - gck_stringForKey:withDefaultValue:
 查找具有指定后备值的键的 NSString 值。更多...
 
(nullable NSString *) - gck_stringForKey:
 查找回退值为 nil 的键的 NSString 值。更多...
 
(NSInteger) - gck_integerForKey:withDefaultValue:
 查找具有指定后备值的键的 NSInteger 值。更多...
 
(NSUInteger) - gck_uintegerForKey:withDefaultValue:
 查找具有指定后备值的键的 NSUInteger 值。更多...
 
(NSInteger) - gck_integerForKey:
 查找回退值为 0 的键的 NSInteger 值。更多...
 
(NSUInteger) - gck_uintegerForKey:
 查找回退值为 0 的键的 NSUInteger 值。更多...
 
(double) - gck_doubleForKey:withDefaultValue:
 查找具有指定后备值的键的 double 值。更多...
 
(double) - gck_doubleForKey:
 查找回退值为 0.0 的键的 double 值。更多...
 
(BOOL) - gck_boolForKey:withDefaultValue:
 查找具有指定后备值的键的 BOOL 值。更多...
 
(BOOL) - gck_boolForKey:
 查找回退值为 NO 的键的 BOOL 值。更多...
 
(nullable NSDictionary *) - gck_dictionaryForKey:
 查找回退值为 nilNSDictionary 值。更多...
 
(nullable NSArray *) - gck_arrayForKey:
 查找回退值为 nil 的键的 NSArray 值。更多...
 
(nullable NSURL *) - gck_urlForKey:
 查找回退值为 nil 的键的 NSURL 值。更多...
 

方法详细信息

- (nullable NSString *) gck_stringForKey: (NSString *)  key
withDefaultValue: (nullable NSString *)  defaultValue 

查找具有指定后备值的键的 NSString 值。

Parameters
keyThe key.
defaultValueThe 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

查找回退值为 nil 的键的 NSString 值。

Parameters
keyThe key.
返回
键的值(如果找到它,则为 NSString;否则为 nil)。
- (NSInteger) gck_integerForKey: (NSString *)  key
withDefaultValue: (NSInteger)  defaultValue 

查找具有指定后备值的键的 NSInteger 值。

Parameters
keyThe key.
defaultValueThe 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
keyThe key.
defaultValueThe default value to return if the key is not found or if its value is not an NSNumber.
返回
如果找到了键的值,则为 NSNumber;否则为默认值。
- (NSInteger) gck_integerForKey: (NSString *)  key

查找回退值为 0 的键的 NSInteger 值。

Parameters
keyThe key.
返回
键的值(如果找到了键,且为 NSNumber);否则为 0
- (NSUInteger) gck_uintegerForKey: (NSString *)  key

查找回退值为 0 的键的 NSUInteger 值。

Parameters
keyThe key.
返回
键的值(如果找到了键,且为 NSNumber);否则为 0
- (double) gck_doubleForKey: (NSString *)  key
withDefaultValue: (double)  defaultValue 

查找具有指定后备值的键的 double 值。

Parameters
keyThe key.
defaultValueThe 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
keyThe key.
返回
键的值(如果找到了键,且为 NSNumber);否则为 0.0
- (BOOL) gck_boolForKey: (NSString *)  key
withDefaultValue: (BOOL)  defaultValue 

查找具有指定后备值的键的 BOOL 值。

Parameters
keyThe key.
defaultValueThe 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
keyThe key.
返回
键的值(如果找到了键,且为 NSNumber);否则为 NO
- (nullable NSDictionary *) gck_dictionaryForKey: (NSString *)  key

查找回退值为 nilNSDictionary 值。

Parameters
keyThe key.
返回
键的值(如果找到了键,且为 NSDictionary;否则为 nil)。
- (nullable NSArray *) gck_arrayForKey: (NSString *)  key

查找回退值为 nil 的键的 NSArray 值。

Parameters
keyThe key.
返回
键的值(如果找到了键,且为 NSArray),否则为 nil
- (nullable NSURL *) gck_urlForKey: (NSString *)  key

查找回退值为 nil 的键的 NSURL 值。

Parameters
keyThe key.
返回
键的值,为 NSURL(如果找到且为 NSURL);否则为 nil