Reputation: 167
I have this statement that im trying to figure out how to use in core data.
SELECT
(3963.0 * acos(sin(".$StartLat."/57.2958) * sin(latitude/57.2958) + cos(".$StartLat."/57.2958) * cos(latitude/57.2958) * cos(longitude/57.2958 - ".$StartLon."/57.2958))) as distance
FROM locations
ORDER BY distance
LIMIT 0, 10
Im guessing this is the part i need to modify:
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Title" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
Thanks in advance.
Upvotes: 4
Views: 783
Reputation: 243156
Simple answer: you can't.
Real answer: you haven't understood what Core Data is.
Core Data is a framework for abstracting the persistence of objects from their in-memory representation. It is an object management framework. You interact with it via objects. You do not create queries. You do not execute SQL. You request objects. Full blown, NSObject
subclasses.
Please go read the Core Data Programming Guide.
(sorry if this comes off as harsh, but this is such a commonly mis-understood thing that it bears being totally explicit)
Upvotes: 4