0

I am using a custom point annotation that includes an image. I am getting several errors such as "Computed property must have an explicit type" and "Variable with getter/setter cannot have an initial value" with the var annotation line. If I fix one another pops up. Does anyone know how to achieve this in Swift 3?

func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

        let eventPageViewController:EventPageViewController = storyboard?.instantiateViewController(withIdentifier: "EventPage") as! EventPageViewController

        var annotation = view.annotation as? CustomPointAnnotation{
            eventPageViewController.photo = annotation?.imageName
        }

        self.present(eventPageViewController, animated: true, completion: nil)
    }

Here is the Custom Point Class:

class CustomPointAnnotation: MKPointAnnotation {
    var imageName: UIImage!
}
Steve
  • 1,121
  • 1
  • 12
  • 32

1 Answers1

0

Here is the solution that worked for me:

let annotation1 = view.annotation as! CustomPointAnnotation
eventPageViewController.photo = annotation1.imageName
Steve
  • 1,121
  • 1
  • 12
  • 32