So I was able to have the annotation's callout animate when the selected table cell was selected like so. Quite simple due to the indexPath.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let indexPath = indexPath.row
myMap.selectAnnotation(pinArray[indexPath] , animated: true)
}
However, I do not understand how to achieve this when I select the annotation and want the table cell to light up. I've been attempting to set a var to indexPath but because the annotation has no subscript, I am unable to perform this. Therefore, how would I be able to accomplish the annotation to selected cell logic?
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
//Magic
}
Update - currently the code I have to highlight the table cell correlated to the map annotation is this.
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
let index = pinArray.index(of: view.annotation as! AnnotationPin)
let indexPath = IndexPath(row: index!, section: 0)
myTable.selectRow(at: indexPath, animated: true, scrollPosition: .top)
}
Unfortunately, I receive this error message when I click on a map annotation.
-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:]: row (72) beyond bounds (17) for section (0).
I don't understand as the array only has 12 records tops, so I completely don't understand how a row above 15 can be mentioned to be beyond bounds.