I'm trying to use the "selected" property in MKAnnotationView ( discussed here ), this is for the user to be able to delete a selected annotation...
The following piece of code should find the selected pin in MKMapView and remove it:
CSMapAnnotation *a;
for(a in [mapView annotations])
{
if([a selected]) //Warning: 'CSMapAnnotation' may not respond to '-selected'
{
[mapView removeAnnotation:a];
}
}
Where CSMapAnnotation is my Custom Map Annotation defined like this:
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
// types of annotations for which we will provide annotation views.
typedef enum {
kCMapAnnotationTypeStart = 0,
kCMapAnnotationTypeCheckpoint = 1,
kCMapAnnotationTypeEnd = 2
} CSMapAnnotationType;
@interface CSMapAnnotation : NSObject <MKAnnotation>
{
CLLocationCoordinate2D coordinate;
CSMapAnnotationType annotationType;
NSString* title;
NSString* userData;
}
-(id) initWithCoordinate:(CLLocationCoordinate2D)inCoordinate
annotationType:(CSMapAnnotationType) annotationType
title:(NSString*)title;
- (BOOL) isEqualToAnnotation:(CSMapAnnotation *) anAnnotation;
@property (nonatomic, readwrite) CLLocationCoordinate2D coordinate;
@property (nonatomic, readwrite) CSMapAnnotationType annotationType;
@property (nonatomic, retain) NSString* title;
@property (nonatomic, retain) NSString* userData;
I think that because I'm not really "inheriting" from MKAnnotationView
, CSMapAnnotation
will not respond to selected
.
What would be the best way to fix this issue ??