Overview
A category that adds some convenience methods to NSDictionary for setting and safely looking up values of various types.
These methods are particularly useful for getting and setting fields of JSON data objects.
Instance Method Summary | |
(NSString *__nullable) | - gck_stringForKey:withDefaultValue: |
Looks up an NSString value for a key, with a given fallback value. More... | |
(NSString *__nullable) | - 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... | |
(NSDictionary *__nullable) | - gck_dictionaryForKey: |
Looks up an NSDictionary value for a key, with a fallback value of nil . More... | |
(NSArray *__nullable) | - gck_arrayForKey: |
Looks up an NSArray value for a key, with a fallback value of nil . More... | |
(NSURL *__nullable) | - gck_urlForKey: |
Looks up an NSURL value for a key, with a fallback value of nil . More... | |
(void) | - gck_setStringValue:forKey: |
Sets an NSString value for a key. More... | |
(void) | - gck_setIntegerValue:forKey: |
Sets an NSInteger value for a key. More... | |
(void) | - gck_setUIntegerValue:forKey: |
Sets an NSUInteger value for a key. More... | |
(void) | - gck_setDoubleValue:forKey: |
Sets a double value for a key. More... | |
(void) | - gck_setBoolValue:forKey: |
Sets a BOOL value for a key. More... | |
Method Detail
- (NSString *__nullable) gck_stringForKey: | (NSString *) | key | |
withDefaultValue: | (NSString *__nullable) | defaultValue | |
- (NSString *__nullable) gck_stringForKey: | (NSString *) | key |
- (NSInteger) gck_integerForKey: | (NSString *) | key | |
withDefaultValue: | (NSInteger) | defaultValue | |
- (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 |
- (NSUInteger) gck_uintegerForKey: | (NSString *) | key |
Looks up an NSUInteger value for a key, with a fallback value of 0
.
- Parameters
-
key The key.
- Returns
- The value of the key, if it was found and was an NSNumber; otherwise
0
.
- (double) gck_doubleForKey: | (NSString *) | key | |
withDefaultValue: | (double) | defaultValue | |
- (double) gck_doubleForKey: | (NSString *) | key |
Looks up a double value for a key, with a fallback value of 0.0
.
- Parameters
-
key The key.
- 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 | |
- (BOOL) gck_boolForKey: | (NSString *) | key |
Looks up a BOOL value for a key, with a fallback value of NO
.
- Parameters
-
key The key.
- Returns
- The value of the key, if it was found and was an NSNumber; otherwise
NO
.
- (NSDictionary *__nullable) gck_dictionaryForKey: | (NSString *) | key |
Looks up an NSDictionary value for a key, with a fallback value of nil
.
- Parameters
-
key The key.
- Returns
- The value of the key, if it was found and was an NSDictionary; otherwise
nil
.
- (NSArray *__nullable) gck_arrayForKey: | (NSString *) | key |
- (NSURL *__nullable) gck_urlForKey: | (NSString *) | key |
- (void) gck_setStringValue: | (NSString *) | value | |
forKey: | (NSString *) | key | |
Sets an NSString value for a key.
- Parameters
-
value The value. key The key.
- (void) gck_setIntegerValue: | (NSInteger) | value | |
forKey: | (NSString *) | key | |
Sets an NSInteger value for a key.
- Parameters
-
value The value. key The key.
- (void) gck_setUIntegerValue: | (NSUInteger) | value | |
forKey: | (NSString *) | key | |
Sets an NSUInteger value for a key.
- Parameters
-
value The value. key The key.
- (void) gck_setDoubleValue: | (double) | value | |
forKey: | (NSString *) | key | |
Sets a double value for a key.
- Parameters
-
value The value. key The key.
- (void) gck_setBoolValue: | (BOOL) | value | |
forKey: | (NSString *) | key | |
Sets a BOOL value for a key.
- Parameters
-
value The value. key The key.