Search code examples
xcodemkannotation

MKAnnotation undeclared


I have an error with this code:

MKAnnotation *ann = [MKAnnotation alloc];

Error:

MKAnnotation undeclared

I already import the following:

#import <MapKit/MapKit.h>
#import <MapKit/MKAnnotation.h>

Any idea how to fix this?


Solution

  • MKAnnotation is not a class - it is a protocol defining an interface to objects that can act as annotations on map - so any object that conforms to that protocol (i.e. implements all required methods) can be used in its place.