How to check that CLLocationCoordinate2D is not empty?

A very old topic, but I needed it now and I fixed my issue with the help of Klaas Hermanns, with a tiny change.

Instead of

if( myCoordinate ==  kCLLocationCoordinate2DInvalid ) {
  NSLog(@"Coordinate invalid");
}

I had to use

if (CLLocationCoordinate2DIsValid(myCoordinate)) {
  NSLog(@"Coordinate valid");
} else {
  NSLog(@"Coordinate invalid");
}

Maybe this will help someone else 🙂

Edit:

As pointed out, the initialization, as covered in Klaas his post, is still necessary.

Leave a Comment