为什么 CoreLocation (Mac OS X) 不记得我选择允许使用它?

Why is CoreLocation (Mac OS X) not remembering my choice to allow its use?

我可能很愚蠢,但我无法弄清楚为什么会发生以下情况:

我在 Mac OS X 上有一个使用 CoreLocation 的应用程序。下面是相关代码:

它每次启动时都会请求使用我的位置的权限,并且永远不会记得我已经授予使用位置数据的权限。

该应用从未出现在 'Privacy' 首选项窗格中。

我是不是漏掉了什么?

谢谢。

#pragma mark - General Instance Methods

- (void)determineLocation
{
    if (self.locationManager)
    {
        DDLogWarn(@"determinLocation called, but we already have a locationManager instance variable...");
        DDLogWarn(@"This is a bug.");
    }

    self.currentlocationName = @"Location unknown";
    if (![CLLocationManager locationServicesEnabled])
    {
        DDLogWarn(@"Location Services not enabled.");
        [self fallBackToHardcodedLocation];
        return;
    }

    //  Location services are available.
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;


    //  Coarse-grained location accuracy required.
    self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
    self.locationManager.distanceFilter = 1000; // meters - 1km
    [self.locationManager startUpdatingLocation];
}



#pragma mark - Location Manager Delegate Methods


- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
    DDLogVerbose(@"Our authorisation to use the location manager has changed.");
    switch (status) {
        case kCLAuthorizationStatusNotDetermined:
            DDLogError(@"LocationManager Authorisation status not determined. (User hasn't chosen yet)");
            break;

        case kCLAuthorizationStatusAuthorized:
            DDLogVerbose(@"We are now authorised for locationServices.");
            [self.locationManager startUpdatingLocation];
            break;

        case kCLAuthorizationStatusDenied:
            DDLogWarn(@"LocationManager: We are now explicitly denied!");
            [self.locationManager stopUpdatingLocation];
            break;

        case kCLAuthorizationStatusRestricted:
            DDLogWarn(@"LocationManager We are now restricted! (not authorised - perhaps due to parental controls...)");
            [self.locationManager stopUpdatingLocation];
            break;

        default:
            break;
    }
}

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    //  Main callback for location discovery..§

    CLLocation* location = [locations lastObject];
    NSDate* eventDate = location.timestamp;
    NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
    if (abs(howRecent) < 15.0)
    {
        // Event is recent. Do something with it.
        if (location.horizontalAccuracy > 1000)
        {
            DDLogWarn(@"Location Accuracy is worse than 1km, discarding...");
        } else {
            [self updateLocation:location];
        }
        return;
    }

    DDLogWarn(@"Stale location data...");
    [self updateLocation:location];
}

它总是请求许可:(kCLAuthorizationStatusNotDetermined 似乎总是这样。)

 2015-02-07 01:03:36:127 Central Heating[2260:30b] LocationManager Authorisation status not determined. (User hasn't chosen yet)

(对话框文本:"Central Heating" 想使用您的当前位置。天气预报需要您的位置。[不允许] [确定])

如 Gordon 所述,此问题已通过签署应用程序得到解决。