Objective c 无法获取GPS位置“;BSXPCMessage收到消息错误:连接中断;

Objective c 无法获取GPS位置“;BSXPCMessage收到消息错误:连接中断;,objective-c,gps,Objective C,Gps,我正在尝试获取位置“纬度和经度”。 我所做的步骤如下: 在CurrentLocationViewController.m中: @implementation CurrentLocationViewController { CLLocationManager *locationManager; } - (id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) {

我正在尝试获取位置“纬度和经度”。 我所做的步骤如下:

在CurrentLocationViewController.m中:

@implementation CurrentLocationViewController {
    CLLocationManager *locationManager;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
    if ((self = [super initWithCoder:aDecoder])) {
        locationManager = [[CLLocationManager alloc] init];
    }
    return self;
}


- (IBAction)getLocation:(id)sender {
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
    [locationManager startUpdatingLocation];
}

#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    NSLog(@"didFailWithError %@", error);
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    NSLog(@"didUpdateToLocation %@", newLocation);
    CLLocation *currentLocation = newLocation;

    if (currentLocation !=nil) {
        self.longitudeLabel.text = [NSString stringWithFormat:@"%0.8f", currentLocation.coordinate.longitude];
        self.latitudeLabel.text = [NSString stringWithFormat:@"%0.8f", currentLocation.coordinate.latitude];
    }
}
然后在CurrentLocationViewController.h中

#import <CoreLocation/CoreLocation.h>
@interface CurrentLocationViewController : UIViewController <CLLocationManagerDelegate>
我在每个方法上都设置了断点,即使在运行应用程序时,我在控制台中收到消息:BSXPCMessage received error for message:Connection interrupted


有什么想法吗?

我收到了相同的错误消息,仍然无法修复“BSXPCMessage”错误,但是关于位置部分,我猜您在iOS 8上运行的是iOS 7版本代码? 如果是,请尝试以下方法:

  • [locationManager请求始终授权]
    [locationManager请求未使用授权时]
    添加到
    [locationManager startUpdatingLocation]
  • 打开Info.plist,将
    nsLocationWhenUsageDescription
    NSLocationAlwaysUsageDescription
    添加到带有消息的“信息属性列表”中

  • 就是这样,希望这能帮助您。

    在使用AVFoundation时收到相同的错误消息。图像和视频。这与你的工作无关