I have created my Model, Entities, Properties and Relationships in Xcode. How are the classes for my Entities created? Do I have to manually create them?
To make a new class in Xcode it is advised to make a new file separate from the other code and call the class. This can be done by making a new file. To make a new file, click on File, and then New → File. A selection screen will come up, for an iphone app, select cocoa touch and objective C class.
Get our help adding Core Data to your project So, with your existing project open, create a new project in Xcode (⇧⌘N) and select a Single View App, you can call it whatever you like as we'll be deleting it when we're done. You'll see the “Use Core Data” checkbox on the project options screen, make sure it is checked.
Overview. After you create a data model file as described in Creating a Core Data Model, set up the classes that collaboratively support your app's model layer. These classes are referred to collectively as the Core Data stack.
You can do this without leaving Xcode at all (see end of answer for Xcode 4 instructions):
I picked this up on page 143 of More iPhone 3 Development
Alternatively, you can just select one or more of the entities in the entity list, as shown below:
And then press ⌘N to bring up the New file dialog shown above. If you accept the default location using this alternative, the generated classes will be put under your .xcdatamodel. Drag them manually to classes (Ref: Stanford, Developing Apps for iOS: ep. 12. Core Data and Table Views).
For Xcode 4, simply bring up the New file dialog (⌘N) and select NSManagedObject subclass from Core Data. The wizard will ask you for which enities it should create classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With