0

i am using parse to retrieve data, how do i pass an object ID from a viwecontroller which has a map view to another view controller ,

 -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{

    [self performSegueWithIdentifier:@"MapToDeal" sender:view.annotation];
    NSLog(@"%@",view.annotation.title);
}
Binarian
  • 12,296
  • 8
  • 53
  • 84
mugunthan
  • 77
  • 1
  • 10

1 Answers1

0

write this method in .m file

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString: @"MapToDeal"])
  {
    DetailViewController *detailViewController = [segue destinationViewController];

    detailViewController.annotview = sender; //here annoteview is  object in DetailViewcontroller
  }
}

or you can also do like this

In mapView Delegate method

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    [self performSegueWithIdentifier:@"MapToDeal" sender:view];
}

In prepareForSegue:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([[segue identifier] isEqualToString:@"MapToDeal"])
    {
        MapPoint *annotation = (MapPoint *)view.annotation;

        DetailViewController *dvc = segue.destinationViewController;
        dvc.name = annotation.name;
        dvc.anyproperty = annotation.anyproperty;

    }
}
Bhoomi Jagani
  • 2,413
  • 18
  • 24