Creating Undo Transactions

Build your Core Data updates into undo transactions by bracketing them into undo groupings. The beginUndoGrouping and endUndoGrouping calls appear before and after context updates. Specify an action name that describes the operation that just took place. This action name is primarily used for shake-to-undo support (for example, “Undo delete?”). It also helps document the action you’re expressing.

The braces used in the following undo-grouping sample are purely stylistic. You do not need to include them in your code. They are provided to highlight the transactional nature that underlies undo groupings:

// Delete request if (editingStyle == UITableViewCellEditingStyleDelete) {     NSManagedObject ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.