Rethinking Edits

When working with Core Data–powered tables, Recipe 12-3 doesn’t let users reorder rows. That’s because its fetch requests sort the data, not users. Recipe 12-3’s tableView:canMoveRowAtIndexPath: method hard-codes its result to NO. Yes, you can work around this by introducing a custom row position attribute. Much of the time you won’t want to. Recipe 12-3 shows a common use case.

In a similar vein, make sure you coordinate any database edits to your data sources. With Core Data–driven tables, these changes may come from user requests (swiping, pressing +, and so forth) and also from the undo manager. By subscribing to the fetched results controller as its delegate, you’ll know whenever data has updated from undo actions. Use the ...

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.