Book Image

Core Data iOS Essentials

Book Image

Core Data iOS Essentials

Overview of this book

Core Data is the essential ingredient in data driven iOS apps. It's used for storing, retrieving, and manipulating application data in databases, XML, and binary formats. It's an essential component for iPhone, iPod Touch, and iPad apps.Core Data Essentials provides a clear, readable guide to the most useful aspects of Core Data. Built around a realistic example app, the book showcases the most important aspects of Core Data development in the context of a complete, functioning app written in Objective C.The book starts with a tour of how the app works. Then you'll see how to easily display data using the Table View. You'll learn how to develop an appropriate data model that fits the needs of your app, then implement that model as updatable data objects. You'll see how to update data and build relationships between objects and learn how Core Data can work with search, and how to provide your users with friendly data editing features.
Table of Contents (19 chapters)
Core Data iOS Essentials
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Appendix

Adding the MasterProduct entity to the Data Model


We need an extra entity to store the information of different products that a vendor is supposed to sell through this application. The information of master product includes product name, price, quantity in hand, and product image, so the entity that we are going to create will consist of four attributes: itemname, price, quantity, and image. The steps for adding the MasterProduct entity are as follows:

  1. 1. Let us open the Xcode's Data Modeling tool by double-clicking the prob.xcdatamodel file from the Resources group in Xcode Project window.

  2. 2. To add a new entity to our data model, select the + (plus) button at the bottom of the Entity pane or choose Design | Data Model | Add Entity from the menu bar. A blank entity (by default name: Entity) will be added to our data model, which we will rename to MasterProduct. Automatically, a subclass of NSManagedObject will be created for our MasterProduct entity.

  3. 3. To add attributes to our MasterProduct...