Hi,
I have a warning "MyAnnotation does not implement the MKAnnotation protocol" everytime I use this:
[mapView addAnnotation:annotation];
or
[mapView removeAnnotation:mapView.annotations];
Someone have an idea?
Hi,
I have a warning "MyAnnotation does not implement the MKAnnotation protocol" everytime I use this:
[mapView addAnnotation:annotation];
or
[mapView removeAnnotation:mapView.annotations];
Someone have an idea?
(Assumed that you annotation object is an instance of MyAnnotation class)
MKMapView require that its annotation objects conform to MKAnnotation
protocol to ensure they implement certain required methods - otherwise your application can produce errors in run-time. This protocol is defined as follows:
// MKAnnotation.h
@protocol MKAnnotation <NSObject>
// Center latitude and longitude of the annotion view.
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@optional
// Title and subtitle for use by selection UI.
- (NSString *)title;
- (NSString *)subtitle;
@end
That is your MyAnnotation class must define and implement coordinate
property and may also implement 2 optional title
methods. To let compiler know that your class actually conforms to a protocol you must declare your class the following way:
@interface MyAnnotation: NSObject <MKAnnotation> // Or whatever parent class you have