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

时间:2014-10-14 16:47:35

标签: objective-c gps

我正在尝试获取位置" Latitude&经度&#34 ;. 我做的步骤如下:

在CurrentLocationViewController.m中:

@implementation CurrentLocationViewController {
    CLLocationManager *locationManager;
}

然后在CurrentLocationViewController.h

#import <CoreLocation/CoreLocation.h>
@interface CurrentLocationViewController : UIViewController <CLLocationManagerDelegate>

返回CurrentLocationViewController.m:

- (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];
    }
}

我在每个方法上都设置了断点,即使在运行应用程序时,我在控制台中收到了消息:BSXPCMessage收到错误消息:连接中断。

有什么想法吗?

2 个答案:

答案 0 :(得分:2)

我收到了相同的错误消息,仍然无法解决&#39; BSXPCMessage&#39;错误,但关于位置部分,我想你在iOS 8上运行iOS 7版本代码? 如果是这样,试试这个:

  1. [locationManager requestAlwaysAuthorization]
  2. 上方添加[locationManager requestWhenInUseAuthorization][locationManager startUpdatingLocation]
  3. 打开Info.plist,将NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription添加到&#39;信息属性列表&#39;带有消息
  4. 那就是它,希望这可以帮助你。

答案 1 :(得分:0)

使用AVFoundation时收到相同的错误消息。图像和视频。它并不特定于你所做的事情。