문제

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.

도움이 되었습니까?

해결책

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
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top