I am a beginner in Objective C. I am setting a Mapview after selecting a TableRow inside a Navigation controller. I am getting this error which terminates the application.
-[UIView setRegion:animated:]: unrecognized selector sent to instance 0x806b2c0
This is my viewWillAppeer for Mapview
- (void)viewWillAppear:(BOOL)animated {
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = 39.281516;
zoomLocation.longitude= -76.580806;
if (CLLocationCoordinate2DIsValid(location)) {
MKCoordinateRegion mapRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);
[_mapView setRegion:mapRegion animated:YES];
} else {
NSLog(@"Invalid coordinates");
}
}
Header file for this imports mapkit and corelocation and has this property.
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
Header file includes mapkit and coreelocation and making this property strong also didn’t changed anything.
This happened because I previously hooked an outlet on my LocateItemViewController (the controller having map view) named “mapView” and never deleted it from “Connections Inspector”.
see the greyed outlet named “view” under Outlets section, I had a similar one named mapView