使用MKAnnotation
、 私は はそう、私はAdoptingAnAnnotation
という名前のクラスを作成するのMapViewに注釈を追加したいときに私はいくつかの問題を抱えている、 を使用する方法.h
ファイルが続く の#import の#importMKAnnotation
@interface AdoptingAnAnnotation: NSObject {
}
@synthesize latitude;
@synthesize longitude;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (NSString *) title;
- (NSString *) subtitle;
@end
との.mファイルがillegal interface qualifier
のようなエラーメッセージを取得
#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
に従っています文法エラーまたはMKAnnotation
に関する他のエラーはありますか?
.hファイルから@synthesizeを削除すると、http://commondatastorage.googleapis.com/haibo/temp/Screen%20Shot%202012-02-25%20at%202.08のような他のエラーメッセージが表示されます。 54%20 PM.pngこれは何かを宣言しなければならないことを意味します。 – timger
'lattitude'と' longitude'を@synthesizeしようとするなら、あなたの@interfaceのものには@property宣言が必要です。同様に、 'coordinate'のための@property宣言を持っているので、そのプロパティのための@synthesizeディレクティブを持っているか、あなた自身がアクセサーを提供する必要があります。 – Caleb