Domanda

I have to convert an NSNumber to CLLocationDistance for comparing them. So are there any formatter to do that? I searched at internet but i could not find.

È stato utile?

Soluzione

CLLocationDistance is really just a double. All you need is this:

NSNumber *number = ... // some number
CLLocationDistance distance = ... // some distance

if (distance == [number doubleValue]) {
    // they are equal
}

Keep in mind that comparing two double values for equality can appear to fail due to the inexactness of most double values.

if (abs(distance - [number doubleValue]) <= DBL_EPSILON) {
    // they are equal
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top