The same code, I assume that the device actually updates the location twice for some reason, although I only call startUpdatingLocation () once and I run some stopUpdatingLocations () inside doUpdateLocations
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { manager.stopUpdatingLocation() let loc: CLLocation = locations[locations.count - 1] let id = 0 let type = 0 let number = 0 createNewDataPoint(id, loc: loc, type: type, number: number) }
In this case, createNewDataPoint is called twice, creating 2 new datapoints. This happens only once in the simulator, so I assume this has something to do with the actual device and GPS, as the simulator fakes its location.
startUpdatingLocation () only in my code once, per button. Basically, you press the button, go go manager.startUpdatingLocations (), didUpdateLocations hits once on the simulator, twice on the device (identical coordinates) and creates 2 new data points.
The only other code that mentions anything is related to setting accuracy, filter, authorization requests and the previously mentioned startUpdatingLocation (). Is there something I can do to make sure that I don't create twice as many data points as needed?
ios swift cllocationmanager
sdouble
source share