Objective C:尝试初始化 CLLocation 实例时出错
当它遇到以下代码时,我遇到错误(程序崩溃)
CLLocation *userLoc = [[CLLocation alloc] initWithCoordinate:locationManager.location.coordinate];
我尝试用以下代码替换参数,我也得到相同的错误
CLLocation *userLoc = [[CLLocation alloc] initWithCoordinate:mapView.userLocation.coordinate];
任何人都可以建议我在这里使用的用户当前的正确参数是什么地点?
谢谢!
珍
堆栈跟踪:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CLLocation initWithCoordinate:]: unrecognized selector sent to instance 0x1e0620'
I am hitting an error (program crashed) when it hits the following code
CLLocation *userLoc = [[CLLocation alloc] initWithCoordinate:locationManager.location.coordinate];
I tried to replace the argument with the following and I get the same error as well
CLLocation *userLoc = [[CLLocation alloc] initWithCoordinate:mapView.userLocation.coordinate];
Can anyone advise me on what should be the correct argument to use here for the user's current location?
Thanks!
Zhen
Stacktrace:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CLLocation initWithCoordinate:]: unrecognized selector sent to instance 0x1e0620'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据文档,< code>CLLocation 没有名为
initWithCooperative:
的初始值设定项。使用以下其中一项:initWithLatitude:longitude:
initWithCooperative:altitude:horizontalAccuracy:verticalAccuracy:timestamp:
initWithCooperative:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp :
According to the documentation,
CLLocation
does not have an initializer calledinitWithCoordinate:
. Use one of the following:initWithLatitude:longitude:
initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:
initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp: