O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Aaron Hillegass, Christian Keur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building the Core Data Stack

The Core Data stack consists of the classes that interface with your entities as well as the model file that describes the entities to save and load instances to a store (such as the filesystem). You will learn about each component in the stack and what role it plays in Core Data.

Create a new Swift file and name it CoreDataStack. Open this file and declare the CoreDataStack class along with a required initializer that accepts the name of the model file. Do not forget to import the Core Data framework.

i​m​p​o​r​t​ ​F​o​u​n​d​a​t​i​o​n​
i​m​p​o​r​t​ ​C​o​r​e​D​a​t​ac​l​a​s​s​ ​C​o​r​e​D​a​t​a​S​t​a​c​k​ ​{​

 ​ ​ ​ ​l​e​t​ ​m​a​n​a​g​e​d​O​b​j​e​c​t​M​o​d​e​l​N​a​m​e​:​ ​S​t​r​i​n​g​

 ​ ​ ​ ​r​e​q​u​i​r​e​d​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required