22 Core Data

When deciding between approaches to saving and loading for iOS applications, the first question is Local or remote? If you want to save data to a remote server, you will likely use a web service. If you want to store data locally, you have to ask another question: Archiving or Core Data?

Your Homepwner application used keyed archiving to save item data to the filesystem. The biggest drawback to archiving is its all-or-nothing nature: To access anything in the archive, you must unarchive the entire file, and to save any changes, you must rewrite the entire file. Core Data, on the other hand, can fetch a subset of the stored objects. And if you change any of those objects, you can update just that part of the file. ...

Get iOS Programming: The Big Nerd Ranch Guide, 6th 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.