I compare two MKPlacemarks that are each created from a CLPlacemark acquired from CLGeocoder.reverseGeocodeLocation(_:) of the same address, but when I compare those two MKPlacemarks with == they don't equal. Is there a way of determining whether those two placemarks refer to the same location? Are there unique identifers on MKPlacemarks that I could use to determine if those two placemarks are of the same location, such as the name or the title properities of MKPlacemark?
Below is the code you asked for.
I get the MKPlacemarks by creating them from the CLPlacemarks I get from CLGeocoder.reverseGeocodeLocation.
I figured out that what are equal are the MKPlacemark.title propery from CLGeocoder. I noticed that the latitude and longitude properties don't equal for MKPLacemarks of the same location. I think it's like you said -- comparing variables of type Double give the result of false.
geocoder.reverseGeocodeLocation(geoLocation) {
placemarks, error in
guard error == nil else {
print("!!!\n", error!)
return
}
guard let placemarks = placemarks, (placemarks.count > 0) else {
print("!!! No placemarks were found!")
return
}
let clFirstPlacemark = placemarks[0]
self.originalPlacemark = MKPlacemark(placemark: clFirstPlacemark)
} // geocoder.reverseGeocodeLocation(currentLocation)