I'm currently using four lines to unwrap the title from mapViewDidSelectMKAnnotationView.
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if let title = view.annotation?.title {
if let title = title {
// do something with title
}
}
}
Can I do this without having to unwrap things twice? Something like:
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if let title = view.annotation?.title? {
// do something with title
}
}
This answer seems to get really close to the question but doesn't address the case of the deepest property being an optional. It seems like a pretty trivial thing and I'm certain there must be a way but I can't work out the syntax for the life of me.