coredata からフェッチし、Location オブジェクトの配列を取得する mapview があります。Location オブジェクトは、次のようなカスタム NSManagedObjects です。
@property (nonatomic, retain) NSString * ciudad;
@property (nonatomic, retain) NSString * horario;
@property (nonatomic, retain) NSString * codigo;
@property (nonatomic, retain) NSString * nombrePublico;
@property (nonatomic, retain) NSString * telefono;
@property (nonatomic, retain) NSString * direccion;
@property (nonatomic, retain) NSString * coordenadas;
@property (nonatomic, retain) NSString * hrs24;
@property (nonatomic, retain) NSString * driveThru;
@property (nonatomic, retain) NSDate * updatedAt;
次に、配列内のすべての Location オブジェクトをループして、次のように注釈を作成します。
MyLocation *annotation = [[MyLocation alloc] initWithName:storeDescription address:address coordinate:coordinate distance:0];
そして、これらの注釈を配列に追加し、後でボタンを押すだけでそれらをプロットします。
- (IBAction)refreshTapped:(id)sender {
for (id<MKAnnotation> annotation in _mapView.annotations) {
[_mapView removeAnnotation:annotation];
}
for (MyLocation *annotation in self.myLocationsToSort) {
[_mapView addAnnotation:annotation];
}
}
最後に、ユーザーが吹き出しの開示ボタンをタップしたら、オブジェクトを UIViewController に渡したいと思います。まず、注釈を作成します。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
それから私はこれをします:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{
if (![view.annotation isKindOfClass:[MyLocation class]])
return;
[self performSegueWithIdentifier:@"DetailVC" sender:view];
}
セグエは詳細テーブルビューを呼び出します。私の質問は、詳細テーブルビューへのオブジェクトの受け渡しをどのように処理すればよいですか?