You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__SwiftValue objCType]: unrecognized selector sent to instance
#14783
Closed
pappalar opened this issue
May 28, 2019
· 4 comments
Being MGLPolylineFeature a interface of protocol MGLFeature
is impossible from subclasses to call super.init(coordinates: coordinates, count: UInt(geometry.count)) as the initializer is not a designated one for the superclass
The code that serializes the MGLPolylineFeature into GeoJSON is tripping over some Swift object in the attributes dictionary that has been cast into an NSValue but isn’t one, likely a Swift struct or enumeration. This document lists the types that are supported in attributes.
Being MGLPolylineFeature a interface of protocol MGLFeature
is impossible from subclasses to call super.init(coordinates: coordinates, count: UInt(geometry.count)) as the initializer is not a designated one for the superclass
Can you speak to why you’re trying to subclass MGLPolylineFeature? If you use an MGLFeature in a shape source, the original object gets lost anyways and you won’t be able to take advantage of your subclass when using runtime styling or feature querying.
It seems to me that the original issue was with a private struct shadowing another subclass struct.
I am using struct to wrap static let keys (attributes string keys).
After some reshaping of the struct I managed to get rid of the exception.
I need to display a quite large amount of different features, each one with its own attributes used in the style for the rendering.
I later on need to interact on the map with those features and I would rather know which type of data I am passing around the app.
To simplify my life I am doing the following:
I created different subclasses of a concrete implementation of MGLFeature (eg: Polyline) that have a convenience initializers for my own different needs.
Internally each subclass is not storing any additional properties but configuring all rendering data in the attributes + storing any additional value I might need later also as an attribute.
The same subclass has an additional initializer that takes a MGLFeature (the one I read from the map) and internally copies over the attributes and coordinates.
This way when I interact with the map I can filter by layer, knowing then which subclass I am interacting with, create back the subclass and use computed properties to access all the attributes without the need to know which keys are used (as I have many and need the object across different part of the app)
This approach works for PointFeatures, as there is no convenience initializer for MGLPointAnnotation
so doing the following in a subclass works:
self.init()
self.coordinate = coordinate
However is currently failing for me for Polylines:
as I cant call the initializer MGLPolylineFeature(coordinates: coordinates, count: UInt(geometry.count)) in a subclass I am forced to do
Steps to reproduce
MGLPolylineFeature
MGLShapeCollectionFeature(shapes: [yourInstance])
MGLShapeSource
sourcesExpected behavior
Mapbox uses the subclass of
MGLPolylineFeature
on the mapActual behavior
App Crashes
due to uncaught exception 'NSInvalidArgumentException', reason: '-[__SwiftValue objCType]: unrecognized selector sent to instance
Question:
Is it possible to subclass Style Primitives?
Notice: Same issue happens with subclasses of
MGLPointFeature
Mapbox SDK versions: 5.0.0
The text was updated successfully, but these errors were encountered: