Creating Core Data Managed Object Subclasses with Xcode
Q: How do I create Core Data managed object subclasses for my entities with Xcode?
A: Follow these steps to create Core Data managed object subclasses with Xcode:
Select your Core Data model in the project navigator.
Xcode displays all your entities in the outline view of the editor area.
Select an entity in the outline view, and verify that the Codegen pop-up menu is set to
Manual/None
in the Data Model inspector as shown in Figure 1. Repeat this step for all entities you want to create Core Data managed object subclasses.
Choose Editor > Create NSManagedObject Subclass… as shown in Figure 2.
In the sheet that appears, select the data model that contain your entities, and click Next.
In the sheet that appears, select the entities whose Core Data managed object subclasses you want to create, and click Next.
In the sheet that appears, select a location to save your files, and click Create.
Xcode creates and saves files named ClassName+CoreDataClass and ClassName+CoreDataProperties for each of your selected entity in the selected location where ClassName is the name of your entity's NSManagedObject
subclass. ClassName+CoreDataClass implements the NSManagedObject
subclass as shown in Figure 6.
ClassName+CoreDataProperties implements a ClassName+CoreDataClass extension (for Swift apps) or category (for Objective-C apps) as shown in Figure 7.
Document Revision History
Date | Notes |
---|---|
2017-03-09 | New document that describes how to create Core Data managed object subclasses with Xcode. |
Copyright © 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-03-09