i have some problem when use MKAnnotation
,
I want to add a Annotation on a MapView
so I create a class named AdoptingAnAnnotation
,
the .h
file follow
#import
#import
@interface AdoptingAnAnnotation: NSObject {
}
@synthesize latitude;
@synthesize longitude;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (NSString *) title;
- (NSString *) subtitle;
@end
and .m file is follow
#import "AdoptingAnAnnotation.h"
@implementation AdoptingAnAnnotation
@synthesize latitude;
@synthesize longitude;
- (id) initWithLatitude:(CLLocationDegrees) lat longitude:(CLLocationDegrees) lng {
latitude = lat;
longitude = lng;
return self;
}
- (CLLocationCoordinate2D) coordinate {
CLLocationCoordinate2D coord = {self.latitude, self.longitude};
return coord;
}
- (NSString *) title {
return @"217 2nd St";
}
- (NSString *) subtitle {
return @"San Francisco CA 94105";
}
@end
Get the error message like illegal interface qualifier
Is my syntax error or other error about the MKAnnotation
?
Your @synthesize
statements belong in the class implementation, not in the interface. This is why you get the "illegal interface qualifier" error. Finally, your class should adopt the MKAnnotation protocol.