NSDictionary(GCKAdditions) 類別

NSDictionary(GCKAdditions) 類別參考

總覽

這個類別會為 NSDictionary 新增一些便利方法,讓您安全地查詢各種類型的值。

這些方法特別適用於取得並設定 JSON 資料物件的欄位。

執行個體方法摘要

(nullable NSString *) - gck_stringForKey:withDefaultValue:
 利用指定備用值查詢鍵的 NSString 值。更多...
 
(nullable NSString *) - gck_stringForKey:
 查詢鍵的 NSString 值 (備用值為 nil)。更多...
 
(NSInteger) - gck_integerForKey:withDefaultValue:
 根據指定的備用值查詢鍵的 NSInteger 值。更多...
 
(NSUInteger) - gck_uintegerForKey:withDefaultValue:
 針對具有指定備用值的鍵查詢 NSUInteger 值。更多...
 
(NSInteger) - gck_integerForKey:
 查詢鍵的 NSInteger 值 (備用值為 0)。更多...
 
(NSUInteger) - gck_uintegerForKey:
 查詢鍵的 NSUInteger 值 (備用值為 0)。更多...
 
(double) - gck_doubleForKey:withDefaultValue:
 針對具有指定備用值的鍵查詢雙精度的值。更多...
 
(double) - gck_doubleForKey:
 查詢鍵的雙精度值,備用值為 0.0更多...
 
(BOOL) - gck_boolForKey:withDefaultValue:
 查詢具有指定備用值的鍵 BOOL 值。更多...
 
(BOOL) - gck_boolForKey:
 查詢鍵的 BOOL 值,備用值為 NO更多...
 
(nullable NSDictionary *) - gck_dictionaryForKey:
 查詢鍵的 NSDictionary 值,備用值為 nil更多...
 
(nullable NSArray *) - gck_arrayForKey:
 查詢鍵的 NSArray 值 (備用值為 nil)。更多...
 
(nullable NSURL *) - gck_urlForKey:
 查詢鍵的 NSURL 值 (備用值為 nil)。更多...
 

方法詳細資料

- (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

查詢鍵的 NSString 值 (備用值為 nil)。

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

查詢鍵的 NSInteger 值 (備用值為 0)。

Parameters
keyThe key.
傳回
鍵的值 (如果有找到且為 NSNumber),否則為 0
- (NSUInteger) gck_uintegerForKey: (NSString *)  key

查詢鍵的 NSUInteger 值 (備用值為 0)。

Parameters
keyThe key.
傳回
鍵的值 (如果有找到且為 NSNumber),否則為 0
- (double) gck_doubleForKey: (NSString *)  key
withDefaultValue: (double)  defaultValue 

針對具有指定備用值的鍵查詢雙精度的值。

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

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

查詢鍵的 BOOL 值,備用值為 NO

Parameters
keyThe key.
傳回
鍵的值 (如果有找到且為 NSNumber),否則為 NO
- (nullable NSDictionary *) gck_dictionaryForKey: (NSString *)  key

查詢鍵的 NSDictionary 值,備用值為 nil

Parameters
keyThe key.
傳回
索引鍵的值 (如果找到且是 NSDictionary),否則為 nil
- (nullable NSArray *) gck_arrayForKey: (NSString *)  key

查詢鍵的 NSArray 值 (備用值為 nil)。

Parameters
keyThe key.
傳回
索引鍵的值 (如果找到且是 NSArray),否則為 nil
- (nullable NSURL *) gck_urlForKey: (NSString *)  key

查詢鍵的 NSURL 值 (備用值為 nil)。

Parameters
keyThe key.
傳回
鍵的值為 NSURL (如果找到且是 NSString),否則為 nil