NSPredicate 'The left hand side for an ALL or ANY operator must be either an NSArray or NSSet'

梦想与她 提交于 2019-11-29 21:06:29

问题


Not totally sure why this isn't working now, i thought it had been working previously. Does anyone see an issue with this FetchRequest construction?

- (NSArray *)entriesForDate:(NSDate *)date {
    NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"Entry"];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY addedOn.unique like %@", [T3Utility identifierForDate:date]];
    request.predicate = predicate;

    NSError *error = nil;
    NSArray *matches = [self.database.managedObjectContext executeFetchRequest:request error:&error];

    return matches;
}

Again, i'm 99% sure that this code has been working until recently, so im thinking perhaps there's something else going on in my code somewhere . . .but when i run it through the debugger this is where is hangs. Here is my error:

The left hand side for an ALL or ANY operator must be either an NSArray or NSSet

Any ideas?

thanks!


回答1:


It seems addedOn is not a to-many relationship. Make sure you use the correct names of your attributes / relationships in the predicate. Also, note that you cannot use a to-one relationship in a "ANY" predicate.



来源:https://stackoverflow.com/questions/12127618/nspredicate-the-left-hand-side-for-an-all-or-any-operator-must-be-either-an-nsa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!