I am setting my map view to delegate yet so I can place an annotation callout on my pin, but I have a geocode that does something else only when a button is clicked. When I set the map view to delegate and I try to place a pin it crashes. How can I fix this?
func action(gestureRecognizer:UIGestureRecognizer) {
let touchPoint = gestureRecognizer.locationInView(self.mapView)
let newCoord:CLLocationCoordinate2D = mapView.convertPoint(touchPoint, toCoordinateFromView: self.mapView)
//var newAnotation = MKPointAnnotation()
//
self.mapView.delegate = self
//
self.newAnotation = MKPointAnnotation()
self.newAnotation.coordinate = newCoord
newAnotation.title = "New Location"
newAnotation.subtitle = "New Subtitle"
//mapView.addAnnotation(newAnotation)
self.pinAnnotationView = MKPinAnnotationView(annotation: self.newAnotation, reuseIdentifier: nil)
self.mapView.centerCoordinate = self.newAnotation.coordinate
self.mapView.addAnnotation(self.pinAnnotationView.annotation!)
}
Screenshot of where it crashes,