aritchie
aritchie

Reputation: 601

NSDate Predicate throws 'Unable to parse the format string' error

I'm trying to use a predicate in my Core Data app. I'm using them throughout the app without any issue apart from this one:

NSPredicate *matchDatePredicate = [NSPredicate predicateWithFormat:@"ANY matches.matchDate < %@", datePlusOne];

This throws the following error: 'Unable to parse the format string "ANY matches.matchDate < %@"'

In a different view controller, the following works:

NSPredicate *matchDatePredicate = [NSPredicate predicateWithFormat:@"ANY matchDate < %@", self.match.matchDate];

the datePlusOne is an NSDate property, as is self.match.matchDate. I've tried various versions of the format string, using >, >=, =, == etc and get the same error every time.

Am I missing something really obvious here??

EDIT: This is the Core Data entities that are being queried. The predicate is searching from MatchStarts to Matches:

enter image description here

Upvotes: 0

Views: 612

Answers (1)

Manish Agrawal
Manish Agrawal

Reputation: 11026

both predicates are different as seems one contains matches.matchDate while other is only matchDate. check if its the problem.

EDIT: for ANY to work either matches has to be to-many relationship or matchDate has to be to-many relationship.
if both are to-one relations then you cannot use ANY.

Upvotes: 1

Related Questions