我在使用MKAnnotation时遇到了一些问题,我想在MapView上添加一个注释,所以我创建了一个名为AdoptingAnAnnotation的类,导入文件遵循# .h #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是我的语法错误或有关MKAnnotation的其他错误
发布于 2012-02-25 13:51:27
您的@synthesize语句属于类实现,而不属于接口。这就是为什么你会得到“非法接口限定符”的错误。最后,您的类应该采用MKAnnotation协议。
发布于 2012-02-25 13:52:48
你发布了你的.h两次...请修改。你的.h中也有合成器,它们属于.m。并确保您实现了这些MKAnnotation方法。
https://stackoverflow.com/questions/9441573
复制相似问题