views:

908

answers:

2

I have an app at the moment which shows various pins on a map. I've tried setting mapView.showsUserLocation = YES; to show the user's current pos, however this crashed my app ("Program received signal: SIGABRT") with the following error message:

Mon Oct 19 12:31:27 unknown Hull Ads[3111] <Error>: *** -[MKUserLocation counter]: unrecognized selector sent to instance 0x10ad60
Mon Oct 19 12:31:27 unknown Hull Ads[3111] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[MKUserLocation counter]: unrecognized selector sent to instance 0x10ad60'
Mon Oct 19 12:31:27 unknown Hull Ads[3111] <Error>: Stack: (...)

This is a little confusing as I haven't used MKUserLocation, or is that the problem?

The app does make use of CoreLocation for other non-related purposes however the app responds in the same way when CoreLocation isn't being used already.

If anyone could help that would be awesome!

Thanks - James

+1  A: 

Be sure to include the following in this method:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
    if ([annotation class] == MKUserLocation.class) {
        return nil;
    }
    ...
}

I do hope you've already fixed this by now ;)

Berend
Hey thanks, I've not been working on this project for a while but I will try it later tonight, thanks!!
ing0
Yes this was the fix, thanks! Hopefully this will help someone else with the same problem in the future!!
ing0
+1  A: 

Thanks Berend for answering the question and james.ingham for asking it! I've been looking for a fix for this problem for months and this thread fixed it for me!

Checking for the MKUserLocation pin type would be the most logical thing to do. But who remembers to do that when implementing viewForAnnotation method.. Even if you are not going to use MKuserlocation in your app it would be safe practice to always do this check to avoid running into problems in the future.

ravinsp
Welcome to stack overflow
ing0