I want an NSPredicate like so:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(latitude - %@) < %@",coordsLatitude, kMaxLatLong];
I basically want to find GPS coords in Core Data that are within a certain distance from userLocation.
-
latitudeis the latitude attribute of each gps entity. -
coordsLatitudeis the latitude of userLocation. -
kMaxLatLongis set to 1
I’m getting a EXC_BAD_ACCESS with this line. I’m thinking it’s due to my predicate just being badly formed, in particular the subtraction operator. However, I could not find anything stating how to use subtraction with NSPredicates, nor with NSExpressions.
I’d do this the other way around.
Work out the minimum and maximum latitude and then use the predicate to find everything between.
i.e.
Then use the compoundPredicate in your fetch request.