What is Core Data concept? Core data is a robust, full-featured persistence tool provided by Apple for persisting data to the iOS file system. Core Data takes care of all the file system management for you.
Within Xcode, Core Data lets us design our data models visually, without writing code, and stores that data model in the .xcdatamodeld file. Single-click the .xcdatamodeld file, and you will be presented with the data modeleditor.The data model editor gives you two distinct views into your data model, depending on the setting of the control in the lower-right corner of the project window. In Table mode, the elements that make up your data model will be shown in a series of editable tables. In Graph mode, you will see a graphical depiction of the same elements. At the moment, both views reflect the same, empty data model. You create entities here in the data model editor, and then in your code, you create managed objects from those entities.
An entity is made up of properties. There are three types of properties:
It is also referred to as a backing store. By default, a Core Data application implements a backing store as a SQLitedatabase stored in the application's Documents directory. Backing stores can also be implemented as binary flat files, or even stored in an XML format. In almost all situations, you should just leave it as the default and use SQLite as your persistent store.
You generally won't work with your persistent store directly, but rather will use something called a managed object context, often referred to as just a context. The context manages access to the persistent store and maintains information about which properties have changed since the last time an object was saved. The context also registers all changes with the undo manager, meaning that you always have the ability to undo a single change or roll back all the way to the last time data was saved.
Let us follow the below steps to create a new project and see how to include core data features in it.
iOS sample project << Previous
Next>> iOS : Designing of the Data Model
Support us generously: contact@lessons2 all.com
Our aim is to provide information to the knowledge seekers.