I have a Core Data Model as follows 1. Task Entity: Attributes objDueDate, Relationship objRecurrence etc. 2. Recurrence Entity: Attributes objEndDate, objStartDate, Relationship tasks, etc.
Task has a many-to-one relationship to Recurrence. Recurrence has an inverse one-to-many relationship with Task. I wish to query the last task of a recurrence sequence by writing an NSFetchRequest predicate as follows
NSPredicate* lobjPredicate = [NSPredicate predicateWithFormat:"objDueDate == [email protected]"]
This fails with an error saying
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to generate SQL for predicate (objDueDate == max:(objRecurrence.tasks.objDueDate))
Can anyone please explain why does this not work?
Thanks in advance....
Explanation of Scenario:
I wish to display tasks sorted by Categories. I also make it compulsory that if you make a task as recurring, all tasks in the recurrence will share the same category. Now there are two sets of tasks: one with recurrence and one without recurrence. Now out of a recurrence sequence (lets say A) I want only one task to be presented to the user. If all tasks in the sequence have been marked done then I wish to present the last done task to the user. If some tasks in the sequence have been marked as done then I wish to present the first Incomplete task to the user.
How can I solve the scenario???