This is my second question today and the first was an incredibly stupid question so I’m fully expecting this one to be as well.
I have a view with an embedded MKMapView.
I want to some how be able to get at this MKMapView? Can I connect it up someway in the xib file? Or failing that … can I just extract it directly from the parent view controller?
I want to do things like use setCoordinates but I can’t figure out how to get at the MKMapView instance to call the function on.
How do I get at the MKMapView object.
In the place that you want to get at it from, set up an outlet. In the .h file, declare a mapview property
MKMapView *mapView;then declare its property with an
IBOutlet@property (nonatomic, retain) IBOutlet MKMapView *mapView;You should be able to control-drag from File’s Owner in your IB file to the mapview in your view to make a connection. Select “mapView” in the popup that appears and your file will be connected to the mapview object. Then you can use the property
mapViewin your .m file to set things on the mapview.[self.mapView setCoordinates:myCoordinates];Make sure you import your framework properly too.