Contents

Creating a Core Data model

Define your app’s object structure with a data model file.

Overview

The first step in working with Core Data is to create a data model file to define the structure of your app’s objects, including their object types, properties, and relationships.

You can add a Core Data model file to your Xcode project when you create the project, or you can add it to an existing project.

Add Core Data to a New Xcode Project

In the dialog for creating a new project, select the Use Core Data checkbox, and click Next.

[Image]

The resulting project includes an .xcdatamodeld file.

[Image]

Add a Core Data Model to an Existing Project

Choose File > New > File and select the iOS platform tab. Scroll down to the Core Data section, select Data Model, and click Next.

[Image]

Name your model file, select its group and targets, and click Create.

[Image]

Xcode adds an .xcdatamodeld file with the specified name to your project.

[Image]

See Also

Related Documentation

Essentials