gpt4 book ai didi

objective-c - Objective-C : Error when trying to initialize instance of CLLocation

转载 作者:行者123 更新时间:2023-11-28 20:46:23 25 4
gpt4 key购买 nike

当遇到以下代码时,我遇到了错误(程序崩溃)

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'

最佳答案

根据documentation , CLLocation 没有名为 initWithCoordinate: 的初始化程序。使用以下之一:

  • initWithLatitude:经度:
  • initWithCoordinate:altitude:horizo​​ntalAccuracy:verticalAccuracy:timestamp:
  • initWithCoordinate:altitude:horizo​​ntalAccuracy:verticalAccuracy:course:speed:timestamp:

关于objective-c - Objective-C : Error when trying to initialize instance of CLLocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6003629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com