NSDictionary(GCKAdditions) 類別

NSDictionary(GCKAdditions) 類別參考

總覽

這個類別可以為 NSDictionary 新增便利方法,設定及安全查詢各種類型的值。

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

執行個體方法摘要

(NSString *__nullable) - gck_stringForKey:withDefaultValue:
 利用指定備用值查詢鍵的 NSString 值。更多...
 
(NSString *__nullable) - 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更多...
 
(NSDictionary *__nullable) - gck_dictionaryForKey:
 查詢鍵的 NSDictionary 值,備用值為 nil更多...
 
(NSArray *__nullable) - gck_arrayForKey:
 查詢鍵的 NSArray 值 (備用值為 nil)。更多...
 
(NSURL *__nullable) - gck_urlForKey:
 查詢鍵的 NSURL 值 (備用值為 nil)。更多...
 
(void) - gck_setStringValue:forKey:
 為鍵設定 NSString 值。更多...
 
(void) - gck_setIntegerValue:forKey:
 為鍵設定 NSInteger 值。更多...
 
(void) - gck_setUIntegerValue:forKey:
 設定鍵的 NSUInteger 值。更多...
 
(void) - gck_setDoubleValue:forKey:
 為鍵設定double 值。更多...
 
(void) - gck_setBoolValue:forKey:
 設定鍵的 BOOL 值。更多...
 

方法詳細資料

- (NSString *__nullable) gck_stringForKey: (NSString *)  key
withDefaultValue: (NSString *__nullable)  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),否則為預設值。
- (NSString *__nullable) 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
- (NSDictionary *__nullable) gck_dictionaryForKey: (NSString *)  key

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

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

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

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

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

Parameters
keyThe key.
傳回
鍵的值為 NSURL (如果找到且是 NSString),否則為 nil
- (void) gck_setStringValue: (NSString *)  value
forKey: (NSString *)  key 

為鍵設定 NSString 值。

Parameters
valueThe value.
keyThe key.
- (void) gck_setIntegerValue: (NSInteger)  value
forKey: (NSString *)  key 

為鍵設定 NSInteger 值。

Parameters
valueThe value.
keyThe key.
- (void) gck_setUIntegerValue: (NSUInteger)  value
forKey: (NSString *)  key 

設定鍵的 NSUInteger 值。

Parameters
valueThe value.
keyThe key.
- (void) gck_setDoubleValue: (double)  value
forKey: (NSString *)  key 

為鍵設定double 值。

Parameters
valueThe value.
keyThe key.
- (void) gck_setBoolValue: (BOOL)  value
forKey: (NSString *)  key 

設定鍵的 BOOL 值。

Parameters
valueThe value.
keyThe key.