tags:

views:

262

answers:

3

hi i hav a code like this in the end i m getting error "the control reaches end of non-void function" how'll i get rid of this? tell me if anyone has the solution.

- (MKAnnotationView *)mapView:(MKMapView *)mapView 
            viewForAnnotation:(id <MKAnnotation>)annotation
{
    NSLog(@"Callouts here");
}
A: 

Your function has to return something because you defined a return type.

If you have nothing to return, simply return nil, although that can cause problems if the caller doesn't expect it.

Philippe Leybaert
A: 

The signature of that method states that it returns a pointer to MKAnnotationView, so you need to return something after your NSLog statement. Try the following:

(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation { NSLog(@"Callouts here"); return nil; }

keno
A: 

I think the reason for the error is that it's technically possible for your method to finish without returning anything (according to the compiler, anyway).

joe