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'
According to the documentation,
CLLocationdoes not have an initializer calledinitWithCoordinate:. Use one of the following:initWithLatitude:longitude:initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp: