Skip to content

Commit

Permalink
Fix Crash Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JannThomas committed Jun 30, 2023
1 parent a65ffac commit 0184889
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ extension MapItemPickerController: MKMapViewDelegate {
self.selectedMapItem = selectedMapItem
}

public func mapView(_ mapView: MKMapView, didDeselect annotation: MKAnnotation) {
let optionalAnnotation: MKAnnotation? = annotation
guard let annotation = optionalAnnotation else { return }
// This function is necessary since the annotation handed to `mapView(_ mapView: MKMapView, didDeselect annotation: MKAnnotation)` is sometimes nil. Casting this within the original function works in debug builds, but not in release builds (due to optimization, propably).
private func didDeselect(optional annotation: MKAnnotation?) {
guard let annotation = annotation else { return }

if let cluster = annotation as? MKClusterAnnotation, cluster == selectedMapItemCluster {
selectedMapItemCluster = nil
Expand All @@ -147,6 +147,10 @@ extension MapItemPickerController: MKMapViewDelegate {
}
}

public func mapView(_ mapView: MKMapView, didDeselect annotation: MKAnnotation) {
didDeselect(optional: annotation)
}

// MARK: Compatibility

public func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
Expand Down

0 comments on commit 0184889

Please sign in to comment.