NSPredicate'ALL或ANY运算符的左侧必须是NSArray或NSSet' [英] NSPredicate 'The left hand side for an ALL or ANY operator must be either an NSArray or NSSet'
问题描述
不完全确定为什么现在不工作,我以为它以前一直在工作。是否有人看到此FetchRequest构造的问题?
- (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];
返回匹配项;
}
再次,我99%确信这个代码一直工作到最近,所以im思考也许有一些其他的东西在我的代码在某个地方。 。 。但是当我运行它通过调试器,这是挂起的地方。这是我的错误:
ALL或ANY运算符的左侧必须是NSArray或NSSet
似乎
code> addedOn 不是一对多的关系。请确保在谓词中使用正确的属性/关系名称。此外,请注意,您不能在任何谓词中使用一对一关系。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!
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.
这篇关于NSPredicate'ALL或ANY运算符的左侧必须是NSArray或NSSet'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!