MKAnnotationsをMKMapViewに配置しようとしています。私は様々な利用可能なチュートリアルで提案されている手順に従っています。私は以下のようにNSobjectクラスからPlaceMark.h/.mファイルを作成しました。 PlaceMark.hMKAnnotationクラスのCLLocationCoordinate2D iVarを初期化できません
#import <Foundation/Foundation.h>
#import <MapKit/MKAnnotation.h>
@interface PlaceMark : NSObject<MKAnnotation>
{
CLLocationCoordinate2D coordinate;
NSString *title;
}
@property (nonatomic,copy) NSString *title;
@property (nonatomic,readonly) CLLocationCoordinate2D coordinate;
@end
PlaceMark.m
MKMapViewを保持している私のViewControllerで#import "PlaceMark.h"
@implementation PlaceMark
@synthesize coordinate,title;
-(void)dealloc
{
[title release];
[super dealloc];
}
@end
、のviewDidLoadで私は、次のしているコード
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
MKCoordinateRegion region;
region.center.latitude=37.3305262;
region.center.longitude=-122.0290935;
region.span.latitudeDelta=0.01;
region.span.longitudeDelta=0.01;
[parkingMap setRegion:region animated:YES];
PlaceMark *ann=[[[PlaceMark alloc]init]autorelease]; // I have also tired it using explicitly defining method -(id)initwithTitle.... but it did not worked.
[email protected]"Test";
ann.coordinate= region.center;
[parkingMap addAnnotation:ann];
}
誰もが私がやっているものを私に教えてくださいすることができ違う?ところで私は、iOSのsdk5.0とXcode4.2を使用していますし、 は、あなたはとてもあなたがそれを設定することはできませんreadonly
としてcoordinate
プロパティを定義した
おかげ スミット
私はそれをしましたが、それでも私は同じエラーを与えていました。 – slonkar
エラーは何ですか? – Anna
それは私に同じエラーを示しました。その後、私はすべてを削除し、再び始まりました。 – slonkar