Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8948797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:05:13+00:00 2026-06-15T13:05:13+00:00

I have an app with a mapview containing various building objects (my own class).

  • 0

I have an app with a mapview containing various building objects (my own class). Each building has an annotation property which all works great and the user can search a table for the desired building, tap a button and it’ll show the relevant annotation.

Now I have a callout button on the annotation which calls a method (showDetails) that pushes a segue to the DetailViewController, but the issue I’m having is getting the right building across to this DetailViewController. All the buildings are stored in an array in the data controller and I’d like to load one from that if possible.

So far I’ve used the controlWasTapped method where I’ve simply put:

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

for (Building* theBuilding in self.datacontroller.masterArray){
if(theBuilding.name isEqualToString:view.annotation.title){
    NSLog(@"theBuilding's name %@", theBuilding.name);
}
}

This works fine and returns the correct building but I’m stumped as to how to get this to the DetailViewController. I have a PrepareForSegue method but how would I get the correct building to it? Also, now that I have DidSelectAnnotation, is there any need for my showDetails method?

I was thinking I could modify the showDetails method so that it took an argument of Building type and then I could provide the Building details in prepareForSegue but if there is a much better way I’d love to know.

So, what’s the best plan? Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:05:14+00:00Added an answer on June 15, 2026 at 1:05 pm

    Declare an instance variable in the class that contains the code you posted.

    Building *buildingOfInterest;
    

    then

    - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
    
        for (Building* theBuilding in self.datacontroller.masterArray)
            if(theBuilding.name isEqualToString:view.annotation.title) {
                  buildingOfInterest = theBuilding;
                  [self performSegueWithIdentifier:@"ShowBuildingSegue" sender:self];
                  break;
        }
    }
    

    then:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
         if ([[segue identifier] isEqualToString:@"ShowBuildingSegue"])
             ((MyBuildingVC *)segue.destinationViewController).building = buildingOfInterest;
    }
    

    and in your target view controller’s header file:

    @interface MyBuildingVC : UIViewController
    @property (strong) Building * building;
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that has a mapview, and it shows 20 pins (from
Have an app that has listings - think classified ads - and each listing
I have a MapView in which I place some ca. 200 Overlays , all
I have custom annotation pin at app: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
I have an app at the moment which shows various pins on a map.
I have an app on the android market, which uses the mapview to display
I have a mapview in my app. My requirement is each time when I
In my app i have a MapView and one annotation. The first touch on
I have an iPad app that has an MKMapView embedded in a UINavigationController which
I am building a Tab Bar App and have a MapView set up on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.