Core Data: Data Storage and Management for iOS, OS X, and iCloud (Pragmatic Programmers)
Core Data is Apple's recommended way to persist data: it's easy to use, built-in, and integrated with iCloud. It's intricate, powerful, and necessary--and this book is your guide to harnessing its power.
Learn fundamental Core Data principles such as thread and memory management, discover how to use Core Data in your iPhone, iPad, and OS X projects by using NSPredicate to filter data, and see how to add iCloud to your applications.
Cocoa expert Marcus Zarra walks you through developing a full-featured application based around the Core Data APIs. You'll build up a single application throughout the book, learning key Core Data principles such as NSPredicate, thread management, and memory management.
Geared toward intermediate to advanced developers, this book gets you comfortable with the basics of Core Data. Then you'll delve deep into the details of the API. You'll explore not only how to get Core Data integrated into your application properly, but even better, how to work with the API's flexibility to create convenience methods to improve your application's maintainability. Learn how to reduce your number of mapping models, integrate your Core Data app with Spotlight and Quick Look, connect your application with sync services, and find out how to use Core Data in a multithreaded environment. By the end of the book, you'll have built a full-featured application, gained a complete understanding of Core Data, and learned how to integrate your application into the iPhone/iPad platform.
This second edition updates all examples for OS X Mountain Lion and iOS 6, gets you up to speed on changes in multithreading, and provides new chapters covering iCloud and NSFetchedResultsController.
What You Need Mac OS X Mountain Lion and iOS 6. This book is for intermediate-level iOS developers.
Validation predicates: Adding, removing, or changing the validation rules Default values: Adding, removing, or changing the default value of an attribute In addition, the following changes to the properties of an entity will also not change the hash of the entity: User info: Adding, removing, or changing the user info key/values Validation predicates: Adding, removing, or changing the validation rules The general distinction between things that do and do not affect version hashes
overload, as discussed in Section 4.5, Access Patterns. Warming Up the Cache As we discussed in Section 4.3, Fetching, it is possible to preload the data into the cache so that it is in memory when we need it. The easiest way to perform this step is to execute a full fetch on a background thread. For example, on launch of our recipe application, we could launch a background thread to retrieve all the Recipe entities. This would allow us to fill the cache with the Recipe entities that
@property (assign) NSDictionary *defaults; - (id)initWithDocument:(NSPersistentDocument*)associatedDocument; - (NSArray*)allParameterNames; - (NSDictionary*)allParameters; @end Our DocumentPreferences object expects to receive a reference to its NSPersistentDocument upon initialization. From the passed-in reference, our DocumentPreferences will be able to access the underlying NSManagedObjectContext. We could also just incorporate this design directly into a
will be transferred to the root object on the receiver. In a more complex example, it would make sense to have a separate object used as the proxy instead of the AppDelegate. With the NSConnection created, we can initialize the NSNetService. The NSNetService handles the broadcasting using Bonjour. Bonjour requires four pieces of information: the domain, type, name, and port. We discovered the port previously, and we defined the domain and type within the PPDistributedProtocol. The last value is
Accessing a To-One Relationship When we are accessing a to-one relationship, we can treat it the same as we do an attribute. Since Core Data is first and foremost an object graph, a to-one relationship can be treated exactly like a property that contains any other object. For example, the relationship between RecipeIngredient and its Recipe is a to-one relationship from the RecipeIngredient side. Therefore, if we were accessing this relationship from that point of view, the code would be as