diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-09-01 06:48:36 -0700 |
---|---|---|
committer | Fredrik Karlsson <bjorn.fredrik.karlsson@gmail.com> | 2016-09-02 22:42:48 +0200 |
commit | 7e208c46cebe5b49d4b7ead9826bbe4229ebabd3 (patch) | |
tree | 6b68b5956a8292a72e95cd80d7e08c8e1346407b | |
parent | d77a13eb7320722c48c8a18240adf99615c4b85f (diff) | |
download | qtlocation-mapboxgl-7e208c46cebe5b49d4b7ead9826bbe4229ebabd3.tar.gz |
[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.
-rw-r--r-- | platform/darwin/src/NSExpression+MGLAdditions.mm | 2 | ||||
-rw-r--r-- | platform/darwin/test/MGLFilterTests.mm | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm index 5f1a1e765a..129c9a740c 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.mm +++ b/platform/darwin/src/NSExpression+MGLAdditions.mm @@ -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 }; } } diff --git a/platform/darwin/test/MGLFilterTests.mm b/platform/darwin/test/MGLFilterTests.mm index 04cb82fac1..5b102e2e86 100644 --- a/platform/darwin/test/MGLFilterTests.mm +++ b/platform/darwin/test/MGLFilterTests.mm @@ -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 |