I want to call a variable (var view) that it is defined in another function (func mapView).
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?{ if annotation is MapSeismometerAnnotation{ if let annotation = annotation as? MapSeismometerAnnotation{ var view: MKPinAnnotationView view = MKPinAnnotationView(annotation: annotation,reuseIdentifier:annotation.identifier) ... ... } @IBAction func pressPlay(_ sender: Any){ //I want to call here the variable view } My class is:
class MapViewController: UIViewController,MKMapViewDelegate,CLLocationManagerDelegate,SCSEarthquakesHandler,SCSPublicSeismometersHandler{ If I define the variable var view: MKPinAnnotationView under the class (outside the function), Xcode return me this error:
Cannot override mutable property 'view' of type 'UIView?' with covariant type 'MKPinAnnotationView'
How can I solve this?