2012-05-04 57 views
9

我有一個核心數據庫,我嘗試使用塊謂詞創建一個抓取請求,但是我得到一個Unknown Predicate錯誤:NSInvalidArgumentException',原因:'謂詞的未知謂詞類型:BLOCKPREDICATE(0x70ad750)'錯誤

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]; 

然後我得到這個錯誤:

NSInvalidArgumentException', reason: 'Unknown predicate type for predicate: BLOCKPREDICATE(0x70ad750)'

難道我做錯了什麼?

+0

您是否使用「未知謂詞類型」? –

+0

你是什麼意思? –

+0

那麼,這就是錯誤信息所說的。 –

回答