我在使用时遇到了一些问题MKAnnotation
,我想在 MapView 上添加一个注释,所以我创建了一个名为的类AdoptingAnAnnotation
,.h
文件遵循 #import #import
@interface AdoptingAnAnnotation: NSObject {
}
@synthesize latitude;
@synthesize longitude;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (NSString *) title;
- (NSString *) subtitle;
@end
和 .m 文件如下
#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
获取错误消息,例如illegal interface qualifier
Is my syntax error 或其他关于MKAnnotation
?