NSExpression contains a built-in function for calculating the distance between two CLLocation
instances. Using it is straightforward:
The result will be an instance of NSNumber
with the distance between the two locations. The arguments can be constant values, key paths, etc.
Because NSPredicate is really a tree of expression operations we can use it there too:
Filtering and searching collections of CLLocation
objects by distances becomes fast and easy - there is no reason to implement your own distance methods.