November 2013
Intermediate to advanced
576 pages
19h 3m
English
To create a new instance of a managed object for data that does not yet exist in your model, a reference to the managed object context is needed. The sample app uses a constant to refer to the ICFAppDelegate instance, which has a property defined for the managed object context:
NSManagedObjectContext *moc = [kAppDelegate managedObjectContext];
To insert data, Core Data needs to know what entity the new data is for. Core Data has a class called NSEntityDescription that provides information about entities. Create a new instance using NSEntityDescription’s class method:
NSManagedObject *newMovie1 = [NSEntityDescription insertNewObjectForEntityForName:@"Movie" ...
Read now
Unlock full access