Jozef Dransfield
Jozef Dransfield

Reputation: 524

EXC_BAD_ACCESS When accessing property of custom MKAnnotation in Swift

I have a custom MKAnnotation that holds a model class Poi.

Which i initialise like so

let annotation = PoiAnnotation()
annotation.poi = poi
...

Then in my calloutAccessoryControlTrapped delegate:

func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
    let annotation = view.annotation as PoiAnnotation

    selectedPoi = annotation.poi

At the point i try to access the .poi property of my annotation i get the EXC_BAD_ACCESS exception. Does anybody know why?

Upvotes: 3

Views: 591

Answers (1)

Magnas
Magnas

Reputation: 4063

This EXC_BAD_ACCESS error and the 'only on simulator' symptom can usually be cleared up with a project clean.

Try 'Product - Clean' Worked for me.

Upvotes: 2

Related Questions