Reputation: 43
I want to add polyLine to mapView , the baidu mapView polyline superclass is BMKPolyLine, it have a class method:
+ (BMKPolyline *)polylineWithPoints:(BMKMapPoint *)points count:(NSUInteger)count;
I creat a subclass BKMyPolyLine, i add a @property colorString
when I get points and used superclass method :
BKMyPolyLine *myLine = [BKMyPolyLine polylineWithPoints:points count:points.count];
myLine.colorString = colorString;
and crash message:
[BMKPolyline setColorString:]: unrecognized selector sent to instance 0x138266fe0'
Upvotes: 1
Views: 180
Reputation: 14824
This isn't "casting" (casting merely informs the compiler; it does not alter actual types)--but you have done something that should return your subclass. It sounds like BMKPolyline
's +polylineWithPoints:count:
method returns a BMKPolyline
, even when it's called on a subclass. Instead you need to override what's known as the "designated initializer", which should be marked in the documentation. But from what I see online, it isn't documented--you probably (annoyingly) need to look into the source of BMKPolyline
to know how to proceed.
Upvotes: 1