Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios, macos] Nested attributes does not get parsed according to the expressions spec. #11874

Closed
fabian-guerra opened this issue May 10, 2018 · 1 comment
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS

Comments

@fabian-guerra
Copy link
Contributor

Given the following JSON:

"properties":{
            "lineStyle":{
                "color":"#00ffff",
            },
}    

Trying to access the lineColor attribute using the following expression
[NSExpression expressionForKeyPath:@"lineStyle.color"] should parse into
@[@"get", @"color", @[@"get", @"lineStyle"]] but gets parsed as @[@"get", @"lineStyle.color"] instead.

/cc @anandthakker @jmkiley @1ec5

@fabian-guerra fabian-guerra added bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS labels May 10, 2018
@1ec5
Copy link
Contributor

1ec5 commented May 10, 2018

It looks like we don’t handle the valueForKeyPath: function’s argument like a key path:

} else if ([function isEqualToString:@"valueForKey:"] || [function isEqualToString:@"valueForKeyPath:"]) {
return @[@"get", self.arguments.firstObject.mgl_jsonExpressionObject, self.operand.mgl_jsonExpressionObject];

However, I’m unsure how this code for key path expressions is incorrect:

case NSKeyPathExpressionType: {
NSArray *expressionObject;
for (NSString *pathComponent in self.keyPath.pathComponents.reverseObjectEnumerator) {
if (expressionObject) {
expressionObject = @[@"get", pathComponent, expressionObject];
} else {
expressionObject = @[@"get", pathComponent];
}
}
return expressionObject;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

No branches or pull requests

3 participants