[ios] Check for bool value with char
We convert NSNumbers (and NSStrings) to the appropriate mbgl value so that we can use NSPredicates to describe mbgl filters we want to apply to style layers at runtime. This change fixes an issue where the conversion from an NSNumber that represented a bool was not recognized as such. encode(bool) returns a 'c' or 'b' on 32 bit and 64 bit systems respectively and objCType of an NSNumber representing a bool always returns 'c'. Now the implementation checks for 'c' always and NSNumbers representing bool don't fall through and trigger the exception.
This commit is contained in:
committed by
Fredrik Karlsson
parent
d77a13eb73
commit
7e208c46ce
@@ -31,7 +31,7 @@
|
||||
return { number.intValue };
|
||||
} else if ((strcmp([number objCType], @encode(double))) == 0) {
|
||||
return { number.doubleValue };
|
||||
} else if ((strcmp([number objCType], @encode(bool))) == 0) {
|
||||
} else if ((strcmp([number objCType], @encode(char))) == 0) {
|
||||
return { number.boolValue };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
NSPredicate *typePredicate = [NSPredicate predicateWithFormat:@"%K == %@", @"$type", @"Feature"];
|
||||
NSPredicate *idPredicate = [NSPredicate predicateWithFormat:@"%K == %@", @"$id", @"1234123"];
|
||||
NSPredicate *specialCharsPredicate = [NSPredicate predicateWithFormat:@"%K == %@", @"ty-’pè", @"sŒm-ethįng"];
|
||||
NSPredicate *booleanPredicate = [NSPredicate predicateWithFormat:@"%K != %@", @"cluster", [NSNumber numberWithBool:YES]];
|
||||
return @[equalPredicate,
|
||||
notEqualPredicate,
|
||||
greaterThanPredicate,
|
||||
@@ -53,7 +54,8 @@
|
||||
inNotInPredicate,
|
||||
typePredicate,
|
||||
idPredicate,
|
||||
specialCharsPredicate];
|
||||
specialCharsPredicate,
|
||||
booleanPredicate];
|
||||
}
|
||||
|
||||
- (void)testAllPredicates
|
||||
|
||||
Reference in New Issue
Block a user