I have an NSSet
of MKAnnotation
s obtained by:
NSSet *locationSet = [map annotationsInMapRect:map.visibleMapRect];
And then I write a NSPredicate
to pass the desired latitude and longitude like this:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"coordinate.latitude == %f AND coordinate.longitude == %f", coord.latitude, coord.longitude];
Now I try to get the desired object by filtering the set:
NSSet *filtered = [locationSet filteredSetUsingPredicate:predicate];
MKAnnotationSubClass *mark = [[filtered allObjects] lastObject];
But get an error saying that my object have not the key I passed:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key latitude.'`
What is the right way to filter this NSSet
of annotations using latitude and longitude arguments?