In this recipe we will learn how to create the associated Core Data model file object definitions for our BooksLibrary
database schema.
Following on from our previous recipe, ensure that our BooksLibrary project file is open.
Before our application can start to use our BooksLibrary
database, we need to create the entity class definitions that will define the variables the database store contains so that we can access these through code.
BooksLibrary.xcdatamodel
file from Project Navigator window.NSManagedObject
classes for.NSManagedObject
class files.In this recipe, we learned about the
NSManagedObject
class, and how we can use this to define the class for the Books
entity that we created in the Core Data store, as well as defining the table schema fields so that when we want to use the Books
class, we can access the attributes at runtime.
The Core Data model wizard generated two files for us. The Books.h
interface file and a Books.m
implementation file. The Books.h
interface file contains each of our entity attribute fields with each being declared based on their object types, and the Books.m
implementation file contains each of our entity attribute fields with each being declared as dynamic
. This defines the entity attribute properties so that they can be used when data is being written or retrieved from the Core Data Model
For more information about the dynamic data type, you can refer to the Apple Developer documentation at the following URL: https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html%23//apple_ref/doc/uid/TP40002154-SW9