I can say that I have no idea how/why this happened.
I have a watchOS 2 app I am working on. I've been working on it all day and it uses core location. It's been getting current location just fine. I need the lat/long in order to make a network call that takes those as parameters.
Anyway, I was field testing and noticed my app crashed. Over and over it was crashing on my watch.
Went home to debug and I noticed that the URL had nil values for the coordinates. Weird, it was working all day every day for months. I haven't made any changes to the Core Location code.
I am using
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
in order to detect when to make a network call. I can only make the network call IF and ONLY IF I have those coordinates. I look at the locations
parameter to see if it is greater than 0 and then I get the lat/long of the last object in it. I've also checked the values in the locationManager
instance I have running.
Anyway, these values are nil
! How can these values be nil if the function locationManager:didUpdateWithLocations:
was called?
I'm very confused because it just happened in the middle of field testing. It was working all day when I was out and about then it just stopped. Other apps like the Maps app on my Apple Watch work okay. Also, all the location permissions are on. I even deleted the app on my iOS device and my watch to start with a fresh app. That didn't fix the problem.
I am only calling the function to stop updating location AFTER I get a successful response from the web server which only kicks off if I get legitimate values from Core Location for lat/long.
Any ideas?