开发者

Objective C: Error when trying to initialize instance of CLLocation

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: '-[CL开发者_StackOverflow中文版Location initWithCoordinate:]: unrecognized selector sent to instance 0x1e0620'


According to the documentation, CLLocation does not have an initializer called initWithCoordinate:. Use one of the following:

  • initWithLatitude:longitude:
  • initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:
  • initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp:
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜