1

を使用するときに問題が発生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 or other error about the MKAnnotation?のようなエラー メッセージを取得します。

4

2 に答える 2

2

あなたの@synthesizeステートメントは、インターフェースではなく、クラスの実装に属しています。これが、「不正なインターフェイス修飾子」エラーが発生する理由です。最後に、クラスは MKAnnotation プロトコルを採用する必要があります。

于 2012-02-25T05:51:26.930 に答える
0

.h を 2 回投稿しました...編集してください。また、.h にはシンセサイザーがあり、それらは .m に属します。そして、これらの MKAnnotation メソッドを必ず実装してください。

于 2012-02-25T05:52:47.520 に答える