In which situations would I want to call -processPendingChanges of NSManagedObjectContext?
In which situations would I want to call -processPendingChanges of NSManagedObjectContext?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The two cases where I’ve used
-processPendingChangeshave involved undo grouping and temporary disabling of undo.For example, I wanted to group all Core Data actions involving the deletion of a particular item (which could lead to deletions of others or other changes to the data model), so I used code like the following:
In order to guarantee that all data model changes triggered by the actions in the
-deleteSelectedOperationmethod would be grouped together, I use-processPendingChangesto make sure they are all registered in the undo grouping block.You can do something similar to ignore all data model changes for the purpose of undo by replacing the undo grouping with
-disableUndoRegistrationand-enableUndoRegistration.