I have a one-to-many relationship form Feedback to Questions in Feedback. The deletion rule is set to Nullify in Question and to Cascade in Feedback (so that when Feedback is deleted it deletes all its questions and when question is deleted it is pointer set to null in feedback.questions).
The problem is when I delete question (just a one question from many that exists in feedback) then I can't access feedback! Though the actual entry is really exist in DB (checked it with MesaSQLite) The code looks like:
FeedbackQuestion * questionToDelete = [FeedbackQuestion findByQuestionId:[entryID integerValue]];
DLog(@"Deleting FeedbackQuestion with ID: %@", questionToDelete.questionID);
success = [questionToDelete MR_deleteEntity];
//success is 1 here
***
// Accessing the feedback which question was deleted
Feedback * feedback = [Feedback findByFeedbackId:feedbackId];
feedback is null here. WHY? What am i doing wrong?
Hm, try maybe the following line after your "//success is 1 here" comment line:
[[NSManagedObjectContext defaultContext] saveToPersistentStoreAndWait];
or, if you don't have the "shorthand-mode" enabled:
[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With