Reputation: 3494
I have a 2 tab application. One of those tabs loads the Map View, and it points to a few coordinates (Annotation pin points). All of this works properly.
But when i keep on clicking the first tab and second continuously i get the following error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Coordinate -180.00000000, -180.00000000'
I don't have a coordinate like that, but this only comes when i keep on clicking the tabs continuously. How can i solve this problem ?
Upvotes: 0
Views: 969
Reputation: 912
Try to use the CLLocationCoordinate2DIsValid property. It will return true if coordinate is correct or false instead.
For example:
if (CLLocationCoordinate2DIsValid(yourCLLocation2D)) {
//coordinate is correct
} else {
//wrong coordinate
}
Upvotes: 4
Reputation: 987
I had the same problem when switching tabs in my app. I fixed the problem by validating the coordinate before assigning it to MKMapView. I did the validation with the following snippet:
if (-90.0f <= coordinate.latitude && coordinate.latitude <= 90.0f &&
-180.0f <= coordinate.longitude && coordinate.longitude <= 180.0f)
{
// assign the validated coordinate to MKMapView
}
Upvotes: 0