Hello All,

I'm trying to query a Core Data database which contains geoLocation information 
for all of the objects of type "Photo" which are within a specified distance of 
a target point, using the following code.

- (NSArray*) photosNearLatitude: (NSNumber*) inLatitude
                      longitude: (NSNumber*) inLongitude
{
  NSExpression *theLHS = [NSExpression expressionForFunction: [NSExpression 
expressionForEvaluatedObject]
                                                selectorName: 
@"distanceFromLatitude:longitude:"
                                                   arguments: [NSArray 
arrayWithObjects:
                                                               [NSExpression 
expressionForConstantValue: inLatitude],
                                                               [NSExpression 
expressionForConstantValue: inLongitude],
                                                               nil]];
    
  NSExpression* theRHS = [NSExpression expressionForConstantValue: [NSNumber 
numberWithDouble: 0.1]];
  
  NSPredicate* thePredicate = [NSComparisonPredicate 
predicateWithLeftExpression: theLHS
                                                                 
rightExpression: theRHS
                                                                        
modifier: NSDirectPredicateModifier
                                                                            
type: NSLessThanOrEqualToPredicateOperatorType
                                                                         
options: 0];

  NSManagedObjectContext* theManagedObjectContext = [self managedObjectContext];
    
  NSFetchRequest* theFetch = [[[NSFetchRequest alloc] init] autorelease];
  theFetch.entity = [NSEntityDescription entityForName: @"Photo"
                                inManagedObjectContext: 
theManagedObjectContext];
  theFetch.predicate = thePredicate;
  
  NSError* theError = NULL;
  NSArray* theResults = [theManagedObjectContext executeFetchRequest: theFetch
                                                               error: 
&theError];
  
  return theResults;
}

The "Photo" class has the following selector.

- (NSNumber*) distanceFromLatitude: (NSNumber*) inLatitude
                         longitude: (NSNumber*) inLongitude

My problem is that when I call "executeFetchRequest", an exception occurs:

2009-11-25 16:55:20.633 Serendipity[8498:a0f] Unsupported function expression 
FUNCTION(SELF, "distanceFromLatitude:longitude:" , 47.71283333333334, -122.225)

-[Photo distanceFromLatitude:longitude:] is never called.

Can anyone suggest what might be going wrong?

- Ron Aldrich

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to