Well, here's the problem: when you execute an NSFetchRequest
, you can only base the predicate on persistent properties. It seems exceedingly unlikely you would have a persistent property that tracks the distance from the current location.
You could add a transient property to your entity that gives the distance from some globally defined location. You'd have to do a fetch request that gets all the objects, and then order them by this transient property.
If you have a lot of objects, you run the risk of filling up your memory quite quickly. And even if you don't, you'll still end up wasting time fetching objects you're never going to use.
I'm guessing you probably had a nifty SQL SELECT
statement that computed the current distance in your previous version. You're not going to be able to replicate that with Core Data.