lenient bool.... web view clean up
This commit is contained in:
parent
adda2f461b
commit
c860e20258
@ -24,6 +24,9 @@
|
||||
- (CGFloat)floatForKey:(nonnull id<NSCopying>)key;
|
||||
- (double)doubleForKey:(nonnull id<NSCopying>)key;
|
||||
|
||||
// Not strict, can accept either string or boolean.
|
||||
- (BOOL)lenientBoolForKey:(nonnull id<NSCopying>)key;
|
||||
|
||||
// Gets an object that is nested using a series of keys or indexes to reach it.
|
||||
// All keys should be of type NSString and is used for nested dictionaries.
|
||||
// All indexes should be of type NSNumber and is used for nested arrays.
|
||||
|
||||
@ -32,6 +32,15 @@
|
||||
return [[self objectForKey:key ofType:[NSNumber class]] boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)lenientBoolForKey:(nonnull id<NSCopying>)key {
|
||||
NSObject *object = [self objectForKey:key];
|
||||
if ([object isKindOfClass:[NSString class]]) {
|
||||
return [((NSString *)object) isEqualToString:@"true"];
|
||||
} else {
|
||||
return [((NSNumber *)([object isKindOfClass:[NSNumber class]] ? object : nil)) boolValue];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)floatForKey:(nonnull id<NSCopying>)key {
|
||||
return [[self objectForKey:key ofType:[NSNumber class]] floatValue];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user