I am trying to make a button that will locate my current location and zoom in. I did try the program and the error show up. Here is the program.
viewController.m
@interface ViewController : UIViewController {
IBOutlet MKMapView *mapview;
}
-(IBAction)findmylocation:(id)sender;
viewController.m
@implementation ViewController
-(IBAction)findmylocation:(id)sender {
mapview.showsUserLocation = YES;
mapview.delegate = self; <-------[WARNING]
[mapview setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
}
The warning error show up on "mapview.delegate = self;" and when i run the application I can't click the button to locate my self. If i click it it will say
.... Application Trying to start MapKit location updates without prompting for location authorization.
Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
This is what warning said on "mapview.delegate = self;" line
Assigning to 'id<MKMapViewDelegate>' from incompatible type 'ViewController *const_strong'
I don't know what is wrong?