I have two tables. Tasks and questions. Both tables have too many relationships between them. Delete the rule from "Tasks" in "Questions" - "DENY", and "Questions for appointments" - "Nullify".
When an assignment is deleted, I want to delete all questions related to this assignment, leaving questions that still contain links with other assignments. This is the reason the DENY removal rule is set from Assignment to Questions.
Before deleting an assignment, I make sure that I remove the link to questions from the assignment, as shown below:
Assignment *assignment = assignment to be deleted;
for (SMQuestion *question in [assignment.questions allObjects])
{
[assignment removeQuestionsObject:question];
}
[[[CoreDataManager sharedObject] managedObjectContext] deleteObject:assignment];
[[[CoreDataManager sharedObject] managedObjectContext] save:&error];
But after deleting a task, none of the questions are deleted from the database. Is there something I'm doing wrong here?