I'm using locationManager(_:didVisit:)
from Core Location to get notified when the user arrives at or leaves a location.
However, I find the callback might be called twice sometimes. Because I would save the data I receive into Core Data, I'd like to remove the duplications in those rare cases.
I have no experience with concurrency in Swift. How can I do to avoid the duplicated ClVisit entries.
func locationManager(_ manager: CLLocationManager, didVisit visit: CLVisit) {
if a visit is already in DB {
return
}
// saves the data to DB
}