Search code examples
iphoneobjective-cxcodeios4mapkit

Invalid UserLocation iPhone MapKit


I am trying to set the mapView's center coordinate to be the users location:

[self.mapView setCenterCoordinate:[[[self mapView] userLocation] coordinate]];

However I am getting a crash which is to do with the user location being invalid:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Coordinate -180.00000000, -180.00000000'

Has anyone else had this error before? Or do you know how to fix this?


Solution

  • Turns out you need to get the [[[[self mapView] userLocation] location] coordinate] rather than the mapView's userLocation's coordinate.