-1

Maybe this question is already asked, but i couldnt find it. The error i get is really giving me a headache!

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MapViewController 0x8095670> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mapView.'

I think this is when the annotation is setted and the event is called. My code:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {

static NSString *identifier = @"MyLocation";
if ([annotation isKindOfClass:[PlaceMark class]]) {

    MKPinAnnotationView *annotationView = 
    (MKPinAnnotationView *)[myMapView dequeueReusableAnnotationViewWithIdentifier:identifier];

    if (annotationView == nil) {
        annotationView = [[MKPinAnnotationView alloc] 
                          initWithAnnotation:annotation 
                          reuseIdentifier:identifier];
    } else {
        annotationView.annotation = annotation;
    }

    annotationView.enabled = YES;
    annotationView.canShowCallout = YES;

    // Create a UIButton object to add on the 
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton setTitle:annotation.title forState:UIControlStateNormal];
    [annotationView setRightCalloutAccessoryView:rightButton];

    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
    [leftButton setTitle:annotation.title forState:UIControlStateNormal];
    [annotationView setLeftCalloutAccessoryView:leftButton];

    return annotationView;
}

return nil; 
}

I'm a bit a newbie to ObjC. But if you need any code for more inspection i'll be pleased to send it you!

j0k
  • 22,600
  • 28
  • 79
  • 90
Paul Oostenrijk
  • 659
  • 8
  • 16
  • 1
    Check that the IBOutlets in the MapViewController xib are all connected correctly. –  Oct 20 '12 at 13:18

1 Answers1

0

I can't see it in the code you've shown, but have you tried to set mapview on your controller somewhere but not set it up as a property? Maybe you used the wrong name in the declaration and you're calling viewcontroller.mapView = ....

Craig
  • 8,093
  • 8
  • 42
  • 74