NSDictionary(GCKAdditions) Category
Stay organized with collections
Save and categorize content based on your preferences.
outlined_flag
The NSDictionary(GCKAdditions) category provides convenience methods for safely looking up values of various types in NSDictionaries.
These methods are particularly useful for working with JSON data objects.
Instance methods are available to look up values of types such as NSString, NSInteger, NSUInteger, double, BOOL, NSDictionary, NSArray, and NSURL, with options for providing a default fallback value.
A category that adds some convenience methods to NSDictionary for safely looking up values of various types.
These methods are particularly useful for getting and setting fields of JSON data objects.
(nullable NSString *) - gck_stringForKey:withDefaultValue:
Looks up an NSString value for a key, with a given fallback value. More...
(nullable NSString *) - gck_stringForKey:
Looks up an NSString value for a key, with a fallback value of nil. More...
(NSInteger) - gck_integerForKey:withDefaultValue:
Looks up an NSInteger value for a key, with a given fallback value. More...
(NSUInteger) - gck_uintegerForKey:withDefaultValue:
Looks up an NSUInteger value for a key, with a given fallback value. More...
(NSInteger) - gck_integerForKey:
Looks up an NSInteger value for a key, with a fallback value of 0. More...
(NSUInteger) - gck_uintegerForKey:
Looks up an NSUInteger value for a key, with a fallback value of 0. More...
(double) - gck_doubleForKey:withDefaultValue:
Looks up a double value for a key, with a given fallback value. More...
(double) - gck_doubleForKey:
Looks up a double value for a key, with a fallback value of 0.0. More...
(BOOL) - gck_boolForKey:withDefaultValue:
Looks up a BOOL value for a key, with a given fallback value. More...
(BOOL) - gck_boolForKey:
Looks up a BOOL value for a key, with a fallback value of NO. More...
(nullable NSDictionary *) - gck_dictionaryForKey:
Looks up an NSDictionary value for a key, with a fallback value of nil. More...
(nullable NSArray *) - gck_arrayForKey:
Looks up an NSArray value for a key, with a fallback value of nil. More...
(nullable NSURL *) - gck_urlForKey:
Looks up an NSURL value for a key, with a fallback value of nil. More...
- (nullable NSString *) gck_stringForKey:
(NSString *)
key
withDefaultValue:
(nullable NSString *)
defaultValue
Looks up an NSString value for a key, with a given fallback value.
Parameters
key The key.
defaultValue The default value to return if the key is not found or if its value is not an NSString .
Returns The value of the key, if it was found and was an NSString ; otherwise the default value.
- (nullable NSString *) gck_stringForKey:
(NSString *)
key
Looks up an NSString value for a key, with a fallback value of nil.
Parameters
Returns The value of the key, if found it was found and was an NSString ; otherwise nil.
- (NSInteger) gck_integerForKey:
(NSString *)
key
withDefaultValue:
(NSInteger)
defaultValue
Looks up an NSInteger value for a key, with a given fallback value.
Parameters
key The key.
defaultValue The default value to return if the key is not found or if its value is not an NSNumber .
Returns The value of the key, if it was found and was an NSNumber ; otherwise the default value.
- (NSUInteger) gck_uintegerForKey:
(NSString *)
key
withDefaultValue:
(NSUInteger)
defaultValue
Looks up an NSUInteger value for a key, with a given fallback value.
Parameters
key The key.
defaultValue The default value to return if the key is not found or if its value is not an NSNumber .
Returns The value of the key, if it was found and was an NSNumber ; otherwise the default value.
- (NSInteger) gck_integerForKey:
(NSString *)
key
Looks up an NSInteger value for a key, with a fallback value of 0.
Parameters
Returns The value of the key, if it was found and was an NSNumber ; otherwise 0.
- (NSUInteger) gck_uintegerForKey:
(NSString *)
key
Looks up an NSUInteger value for a key, with a fallback value of 0.
Parameters
Returns The value of the key, if it was found and was an NSNumber ; otherwise 0.
- (double) gck_doubleForKey:
(NSString *)
key
withDefaultValue:
(double)
defaultValue
Looks up a double value for a key, with a given fallback value.
Parameters
key The key.
defaultValue The default value to return if the key is not found or if its value is not an NSNumber .
Returns The value of the key, if it was found and was an NSNumber ; otherwise the default value.
- (double) gck_doubleForKey:
(NSString *)
key
Looks up a double value for a key, with a fallback value of 0.0.
Parameters
Returns The value of the key, if it was found and was an NSNumber ; otherwise 0.0.
- (BOOL) gck_boolForKey:
(NSString *)
key
withDefaultValue:
(BOOL)
defaultValue
Looks up a BOOL value for a key, with a given fallback value.
Parameters
key The key.
defaultValue The default value to return if the key is not found or if its value is not an NSNumber .
Returns The value of the key, if it was found and was an NSNumber ; otherwise the default value.
- (BOOL) gck_boolForKey:
(NSString *)
key
Looks up a BOOL value for a key, with a fallback value of NO.
Parameters
Returns The value of the key, if it was found and was an NSNumber ; otherwise NO.
- (nullable NSDictionary *) gck_dictionaryForKey:
(NSString *)
key
Looks up an NSDictionary value for a key, with a fallback value of nil.
Parameters
Returns The value of the key, if it was found and was an NSDictionary ; otherwise nil.
- (nullable NSArray *) gck_arrayForKey:
(NSString *)
key
Looks up an NSArray value for a key, with a fallback value of nil.
Parameters
Returns The value of the key, if it was found and was an NSArray ; otherwise nil.
- (nullable NSURL *) gck_urlForKey:
(NSString *)
key
Looks up an NSURL value for a key, with a fallback value of nil.
Parameters
Returns The value of the key as an NSURL , if it was found and was an NSString ; otherwise nil.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[],[]]