CLLocationManager不适用于非无线连接

CLLocationManager不适用于非无线连接

本文介绍了CLLocationManager不适用于非无线连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Mac应用程序,并希望使用核心位置,但是,当我不在wifi上,但使用以太网电缆连接,核心位置(CLLocationManager)报告无法完成操作。



确切的错误讯息是

 操作无法完成。 (kCLErrorDomain error 0.)

如果我总是连接到同一路由器以太网电缆)为什么CLLocationManager只为wifi而不是以太网连接工作?



任何建议都非常感激。



感谢。



编辑:



以下是一些代码。



我将位置管理器定义为一个实例变量,如

  locationManager = [[CLLocationManager alloc]在里面]; 
[locationManager setDelegate:self];
[locationManager setDistanceFilter:ICMinimumUpdateDistance];

然后我监控位置管理器的委托方法,如

   - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{

//在最后更新之前过滤掉点数
NSTimeInterval timeSinceLastUpdate = [newLocation.timestamp timeIntervalSinceDate:dateOfLastUpdate];

if(timeSinceLastUpdate> 0)
{
// Do stuff
}

}



我也使用委托方法检查错误

   - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
{
NSLog(@Location Error:%@,[error localizedDescription]);
}

在上面的代码中,位置管理器更新为无效的newLocation邮票),然后位置管理器调用委托错误方法。

解决方案

如果您打开日期和时间选项卡的时区选项卡,时间窗格在系统首选项,同时通过以太网连接到互联网,它说,连接到无线网络以确定您当前的位置。这使我相信,CoreLocation确实,事实上,需要一个无线连接。


I have a Mac app and would like to use core location, however, when I am not on wifi but connected using an ethernet cable, core location (CLLocationManager) reports that the operation could not be completed.

The exact error message is

The operation couldn't be completed. (kCLErrorDomain error 0.)

If I am always connected to the same router (ie. either wifi or ethernet cable) why does CLLocationManager only work for wifi and not for the ethernet connection?

Any suggestions would greatly be appreciated.

Thanks.

Edit:

Here is some code.

I define my location manager as an instance variable like so

    locationManager = [[CLLocationManager alloc] init];
    [locationManager setDelegate:self];
    [locationManager setDistanceFilter:ICMinimumUpdateDistance];

I then monitor the location manager's delegate method like so,

    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{

// Filter out points before the last update
NSTimeInterval timeSinceLastUpdate = [newLocation.timestamp timeIntervalSinceDate:dateOfLastUpdate];

if (timeSinceLastUpdate > 0)
{
    //Do stuff
}

}

I also check for errors using the delegate method

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    NSLog(@"Location Error:%@", [error localizedDescription]);
}

In the code above, the location manager updates with an invalid newLocation (bad time stamp) and then the location manager calls the delegate error method.

解决方案

I've noticed this too. If you open the Time Zone tab of the Date & Time pane in System Preferences while connected to the internet via ethernet, it says to connect to a wireless network to determine your current location. This leads me to believe that CoreLocation does, in fact, require a wireless connection.

这篇关于CLLocationManager不适用于非无线连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 00:29