O'Reilly logo

Mastering iOS 11 Programming - Second Edition by Donny Wals

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

Adding Core Data to an application

When you create a new project in Xcode, Xcode asks whether you want to add Core Data to your application. If you check this checkbox, Xcode will automatically generate some boilerplate code that sets up the Core Data stack. Prior to iOS 10, this boilerplate code spanned a couple of dozen lines because it had to load the data model, connect to the persistent store, and then it also had to set up the managed object context.

In iOS 10, Apple introduced NSPersistentContainer. When you initialize an NSPersistentContainer, all this boilerplate code is obsolete and the hard work is done by the NSPersistentContainer. This results in much less boilerplate code to obtain a managed object context for your application. ...

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