[ACCEPTED]-How to create classes after creating Core Data model in Xcode for iPhone-core-data
You can do this without leaving Xcode at 13 all (see end of answer for XCode 4 instructions):
- Open your data model so it's visible in the editor pane
- Single click Classes folder in Group & Pane pane
- Now single click anywhere in the diagram pane.
- Press ⌘N to bring up this dialog:
- Finish the wizard to genereate code for one or more classes. Note: you select the classes for which to generate on a later step in the wizard - not shown here.
I 12 picked this up on page 143 of More iPhone 3 Development
Alternatively, you 11 can just select one or more of the entities 10 in the entity list, as shown below:
And 9 then press ⌘N to bring up the New file dialog 8 shown above. If you accept the default location 7 using this alternative, the generated classes 6 will be put under your .xcdatamodel. Drag 5 them manually to classes (Ref: Stanford, Developing Apps for iOS: ep. 12. Core Data and Table Views).
Update 3/26/2011 (Xcode 4):
For XCode 4 4, simply bring up the New file dialog (⌘N) and 3 select NSManagedObject subclass from Core 2 Data. The wizard will ask you for which 1 enities it should create classes.
With Xcode 4.3+, you can just :
- click on your model
- click the Editor Menu
- click Create NSManagedObject subclass
- save the files where you want
And it's 1 done !
You can also use mogenerator. It now includes Xmo’d 2 which seamlessly integrates mogenerator 1 into Xcode.
More Related questions