Number convenience for NSDictionary category

KeyTextColor constant for MFLabel and core ui
Checker for hasText on MFLabel
update molecule protocol for mf label.
separator use molecule protocol
fix to header
This commit is contained in:
Pfeil, Scott Robert 2019-03-04 17:44:26 -05:00
parent d0621c51bb
commit b6d4178e5e
6 changed files with 15 additions and 10 deletions

View File

@ -40,7 +40,7 @@ NSUInteger const TopAlertDismissTime = 5;
}
// The default is yes if not sent by server (for legacy to work as is)
NSNumber *closeButton = [responseInfo objectForKey:KeyCloseButton ofType:[NSNumber class]];
NSNumber *closeButton = [responseInfo optionalNumberForKey:KeyCloseButton];
if (closeButton) {
self.useCloseButton = [closeButton boolValue];
} else {
@ -51,7 +51,7 @@ NSUInteger const TopAlertDismissTime = 5;
// Server driven dismiss time.
if (self.useNewStyle) {
NSNumber *topAlertTime = [responseInfo objectForKey:@"topAlertTime" ofType:[NSNumber class]];
NSNumber *topAlertTime = [responseInfo optionalNumberForKey:@"topAlertTime"];
if (topAlertTime) {
self.topAlertDismissTime = [topAlertTime integerValue];
}

View File

@ -23,6 +23,7 @@
- (NSInteger)integer:(nonnull id<NSCopying>)key;
- (CGFloat)floatForKey:(nonnull id<NSCopying>)key;
- (double)doubleForKey:(nonnull id<NSCopying>)key;
- (nullable NSNumber *)optionalNumberForKey:(nonnull id<NSCopying>)key;
// Not strict, can accept either string or boolean.
- (BOOL)lenientBoolForKey:(nonnull id<NSCopying>)key;

View File

@ -29,7 +29,7 @@
}
- (BOOL)boolForKey:(nonnull id<NSCopying>)key {
return [[self objectForKey:key ofType:[NSNumber class]] boolValue];
return [[self optionalNumberForKey:key] boolValue];
}
- (BOOL)lenientBoolForKey:(nonnull id<NSCopying>)key {
@ -42,15 +42,19 @@
}
- (CGFloat)floatForKey:(nonnull id<NSCopying>)key {
return [[self objectForKey:key ofType:[NSNumber class]] floatValue];
return [[self optionalNumberForKey:key] floatValue];
}
- (double)doubleForKey:(id<NSCopying>)key {
return [[self objectForKey:key ofType:[NSNumber class]] doubleValue];
return [[self optionalNumberForKey:key] doubleValue];
}
- (NSInteger)integer:(nonnull id<NSCopying>)key {
return [[self objectForKey:key ofType:[NSNumber class]] integerValue];
return [[self optionalNumberForKey:key] integerValue];
}
- (nullable NSNumber *)optionalNumberForKey:(nonnull id<NSCopying>)key {
return [self objectForKey:key ofType:[NSNumber class]];
}
- (nullable id)objectChainOfKeysOrIndexes:(nonnull NSArray *)keysOrIndexes {

View File

@ -60,7 +60,7 @@
}
- (BOOL)extendsAppSession {
NSNumber *extendSessionFlag = [self.responseInfoMap objectForKey:@"appSessionExtended" ofType:[NSNumber class]];
NSNumber *extendSessionFlag = [self.responseInfoMap optionalNumberForKey:@"appSessionExtended"];
return !extendSessionFlag || [extendSessionFlag boolValue]; // Default to YES if the key does not exist.
}

View File

@ -67,7 +67,7 @@
if (self = [self initWithPageType:[actionMap stringForKey:KeyPageType] additionalModules:[actionMap array:KeyModuleList] extraParameters:[actionMap dict:KeyExtraParameters]]) {
self.contextRoot = [actionMap string:KeyContextRoot];
self.actionMap = actionMap;
self.customTimeoutTime = [actionMap objectForKey:@"customTimeoutTime" ofType:[NSNumber class]];
self.customTimeoutTime = [actionMap optionalNumberForKey:@"customTimeoutTime"];
self.openSupportPanel = [actionMap boolForKey:KeyOpenSupport];
// Right now server is sending default.... can't uncomment this until they remove default

View File

@ -218,7 +218,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
}
// Adds json to cache with page type key.
NSNumber *shouldCache = [jsonDictionary objectForKey:@"cache" ofType:[NSNumber class]];
NSNumber *shouldCache = [jsonDictionary optionalNumberForKey:@"cache"];
if (!shouldCache || shouldCache.boolValue) {
[weakSelf.pageTypeCache setObject:jsonDictionary forKey:pageType];
}
@ -255,7 +255,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
}
// Adds json to cache with page type key.
NSNumber *shouldCache = [jsonDictionary objectForKey:@"cache" ofType:[NSNumber class]];
NSNumber *shouldCache = [jsonDictionary optionalNumberForKey:@"cache"];
if (!shouldCache || shouldCache.boolValue) {
[weakSelf.moduleCache setObject:obj forKey:key];
}