- [CLLocationManager requestWhenInUseAuthorization] или - [CLLocationManager requestAlwaysAuthorization] ошибка

Это мой код, показывающий как предупреждение, так и синюю точку для текущей позиции на карте:

MapName.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>


@interface MapName : UIViewController <MKMapViewDelegate, CLLocationManagerDelegate>

@property (strong, nonatomic) IBOutlet MKMapView *MapName;
@property (strong, nonatomic) CLLocationManager *locationManager;

@end

MapName.m

- (void)viewDidLoad
{
[super viewDidLoad];

self.locationManager = [[CLLocationManager alloc]init];
self.locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
    [self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];

//Center the map
[self gotoLocation];

//Show current position
_MapName.showsUserLocation = YES;

}

Я добавил ключNSLocationWhenIsUseUsageDescription в виде строки в Info.plist. Я все еще получаю ту же ошибку на XCode.

Ответы на вопрос(6)

Ваш ответ на вопрос