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 |
|
|
| |
針對具有指定備用值的鍵查詢雙精度的值。
- 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
。
- 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 |
|
查詢鍵的 BOOL 值,備用值為 NO
。
- Parameters
-
- 傳回
- 鍵的值 (如果有找到且為 NSNumber),否則為
NO
。
- (nullable NSDictionary *) gck_dictionaryForKey: |
|
(NSString *) |
key |
|
- (nullable NSArray *) gck_arrayForKey: |
|
(NSString *) |
key |
|
查詢鍵的 NSArray 值 (備用值為 nil
)。
- Parameters
-
- 傳回
- 索引鍵的值 (如果找到且是 NSArray),否則為
nil
。
- (nullable NSURL *) gck_urlForKey: |
|
(NSString *) |
key |
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間: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":"其他"
}]