{"action":"closed","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/6095","repository_url":"https://api.github.com/repos/mapbox/mapbox-gl-native","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/6095/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/6095/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/6095/events","html_url":"https://github.com/mapbox/mapbox-gl-native/issues/6095","id":172210822,"number":6095,"title":"Optional style properties treat nil as a function","user":{"login":"1ec5","id":1231218,"avatar_url":"https://avatars.githubusercontent.com/u/1231218?v=3","gravatar_id":"","url":"https://api.github.com/users/1ec5","html_url":"https://github.com/1ec5","followers_url":"https://api.github.com/users/1ec5/followers","following_url":"https://api.github.com/users/1ec5/following{/other_user}","gists_url":"https://api.github.com/users/1ec5/gists{/gist_id}","starred_url":"https://api.github.com/users/1ec5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1ec5/subscriptions","organizations_url":"https://api.github.com/users/1ec5/orgs","repos_url":"https://api.github.com/users/1ec5/repos","events_url":"https://api.github.com/users/1ec5/events{/privacy}","received_events_url":"https://api.github.com/users/1ec5/received_events","type":"User","site_admin":false},"labels":[{"id":77255735,"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/bug","name":"bug","color":"0052cc","default":true},{"id":92400707,"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/iOS","name":"iOS","color":"000000","default":false},{"id":142869898,"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/macOS","name":"macOS","color":"000000","default":false},{"id":425273839,"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/runtime%20styling","name":"runtime styling","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/milestones/47","html_url":"https://github.com/mapbox/mapbox-gl-native/milestones/ios-3.4.1","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/milestones/47/labels","id":2102263,"number":47,"title":"ios-3.4.1","description":null,"creator":{"login":"boundsj","id":63186,"avatar_url":"https://avatars.githubusercontent.com/u/63186?v=3","gravatar_id":"","url":"https://api.github.com/users/boundsj","html_url":"https://github.com/boundsj","followers_url":"https://api.github.com/users/boundsj/followers","following_url":"https://api.github.com/users/boundsj/following{/other_user}","gists_url":"https://api.github.com/users/boundsj/gists{/gist_id}","starred_url":"https://api.github.com/users/boundsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boundsj/subscriptions","organizations_url":"https://api.github.com/users/boundsj/orgs","repos_url":"https://api.github.com/users/boundsj/repos","events_url":"https://api.github.com/users/boundsj/events{/privacy}","received_events_url":"https://api.github.com/users/boundsj/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":1,"state":"open","created_at":"2016-10-30T13:39:48Z","updated_at":"2016-12-01T07:42:37Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2016-08-19T20:09:40Z","updated_at":"2016-12-01T07:42:37Z","closed_at":"2016-12-01T07:42:37Z","body":"On iOS and macOS, properties on MGLStyleLayer classes for optional attributes have somewhat unpredictable nullability. For example, the style specification [defines the `background-color` property](https://www.mapbox.com/mapbox-gl-style-spec/#paint-background-color) as being optional with a default value of `#000000`. If I create an MGLBackgroundStyleLayer and immediately add it to an MGLStyle, the `backgroundColor` property is `nil` rather than the default value of `+[UIColor blackColor]`:\n\n```\n(lldb) po layer.backgroundColor\n nil\n```\n\nThat’s fine; perhaps I could consider the property to be nullable with an implicit default value. But if I set the property to be `nil`, it ends up as a function with no stops:\n\n```\n(lldb) po layer.backgroundColor = [UIColor redColor]\nUIExtendedSRGBColorSpace 1 0 0 1\n\n(lldb) po layer.backgroundColor = nil\n nil\n\n(lldb) po layer.backgroundColor\n<MGLStyleAttributeFunction: 0x7fdc23c09e90, base = 0; stops = {\n}>\n```\n\nTo be sure, setting the property to a non-`nil` constant value does give the expected result:\n\n```\n(lldb) po layer.backgroundColor = [UIColor redColor]\nUIExtendedSRGBColorSpace 1 0 0 1\n\n(lldb) po layer.backgroundColor\nUIExtendedSRGBColorSpace 1 0 0 1\n```\n\nThe SDK should intercept a stop-less function and return `nil` instead.\n\nBetter yet, `mbgl::style::Layer` should have a formal concept of a default value so that we can implement the `null_resettable` semantics in the SDK. That is, an optional property should never return `nil` (instead returning the default value), but you can set the property to `nil` in order to revert it to the default value.\n\n/cc @frederoni @jfirebaugh @ivovandongen\n"}}
{"actor":{"display_login":"1ec5"}}