Search code examples
iosobjective-ccore-datansfetchrequest

Custom fetch comparator


I've just seeded 25k objects into Core Data and therefore will need to perform a comparison of some of the objects before they're fetched; though the Haversine formula. I saw a similar question that advised that all objects must be fetched and then compared, however that will be resource and memory expensive.

Please can you tell me how I can perform this custom comparison through, I assume, a predicate in this case?


Solution

  • Use the predicate to find objects inside a simple lat-long box (min and max values) and then apply any finer grained distance calculation, filter and sorting on the fetch results.