How to check that CLLocationCoordinate2D is not empty?

Shmidt picture Shmidt · Nov 25, 2011 · Viewed 26.3k times · Source

How to check that CLLocationCoordinate2D is not empty?

Answer

Rick van der Linde picture Rick van der Linde · Apr 27, 2012

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.