I have finished the My Locations app upto the last section.
If I start the App and do get locations, it finds my location. Then I can press Stop, then get my locations again and it works.
If I goto Map, pick a location, then get info for that location, then go back to tag a location, stop the service and press get my location, it searches and then times out. It fails with
didFailWithError Error Domain=kCLErrorDomain Code=0 “(null)”
Then pressing get my location never works again, until I restart the App.
I have compared the code tot he tutorial code and can’t find any real differences and everything else works. I put in print statements and they seem to track what is going on, but it doesn’t explain why it keeps timing out.
Is this on the simulator or on a device? Since iOS 9, the simulator has been behaving strangely for me with “fake” locations. But on a real device this definitely shouldn’t happen – if it does, you’ve found a bug somewhere.
I havent looked at the code itself, but Id bet that you are stopping the locationmanager service at some point (perhaps when you press “stop” wherever that is.
Hunt it down by looking for instances of locationmanager and find out where you stop it. It works when you run the app again because you surely have a method that gets called that starts it back up again on launch.
I see clearing the global variable, lastLocationError, but I was wondering if the NSError clears automatically when you read it, or do you have to do something to clear it, otherwise you keep getting the same error.
Also in this code, if the error is location unknown, it doesn’t set the lastLocationError variable.
I took the 06 - Photo Picker code from the tutorials and built it for my Ipad Mini 4 and it behaves the same way, and I basically see the same type error message, so you should be able to duplicate the problem using your own source code.
Somewhat different for me, I don’t get locations at all- this was after setting the plist, locationManager delegate functions, and after implementing authStatus == .denied This is for the Swift 4 version