NSInvalidArgumentException', reason: 'Unknown predicate type for predicate: BLOCKPREDICATE(0x70ad750)' Error
core-data, iphone, nsfetchrequest, objective-c, predicate
Solution
AFAIK you cannot use block predicates with CoreData.
See top voted answer here: NSFetchRequest and predicateWithBlock
The reason being that CoreData cannot translate C-code contained in a block into a SQL query.
Problem
I have a core data database and I am trying to create a fetch request using a block predicate, but I get an Unknown Predicate error: NOTE: employeeToHouse is a property of type House that was created for me when I subclassed NSManagedObject ``` NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Place"]; request.predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { Place *sortPlace = (Place *)evaluatedObject; CLLocation *placeLocation = [[CLLocation alloc] initWithLatitude:sortPlace.latitude.doubleValue longitude:sortPlace.longitude.doubleValue]; CLLocationDistance distance = [placeLocation distanceFromLocation:self.userLocation]; sortPlace.distanceToUser = [NSNumber numberWithDouble:distance]; if(distance<3000) { return YES; } return NO; }]; request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@ "distanceToUser" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]]; [self.loadingView removeSpinner]; [self setupFetchedResultsControllerWithFetchRequest:request]; ``` I then get this error: NSInvalidArgumentException', reason: 'Unknown predicate type for predicate: BLOCKPREDICATE(0x70ad750)' Am I doing something wrong?