私はMKMapView
アプリにを実装しており、-mapView: viewForAnnotation:
動的に配置されたピンとコールアウトをマップ上に表示するためのメソッドを実装しました。私が興味を持っているマップ上の注釈は、Annotation
を実装するという別のクラスで定義されていますMKAnnotation
。メソッドでは、-mapView: viewForAnnotation:
メソッドのannotation
変数を介して供給される変数の値を取得する必要があります。これは、のインスタンスになりますAnnotation
。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]]) {
return nil;
}
if ([annotation isKindOfClass:[Annotation class]]) {
static NSString *identifier = @"RemoteLocation";
MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
//HERE, I NEED TO GET THE VALUE OF annotation's VARIABLE IN ORDER TO ASSIGN THE ANNOTATIONVIEW IMAGE
//annotationView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:annotation.senderPhotoURL]]];
return annotationView;
}
return nil;
}
annotation
問題は、のインスタンスであるから変数の値を取得しようとすると、Annotation
変数にアクセスできないことです。annotation
のインスタンスであるプログラムに通知しAnnotation
て、変数を読み取れるようにするには、何をする必要がありますか?