Why can't I see a Managed Object Class file template in Xcode?
Asked Answered
I

6

8

I created a .xcdatamodel Managed Object Model file in Xcode. I selected that file in Groups & Files. Then I go to File > New... > and nowhere in the iPhone Templates / Cocoa Touch Class templates I see the "Managed Object Class" file template.

Does anyone know what can be wrong?

Imray answered 25/1, 2010 at 21:54 Comment(0)
C
14

I usually need to also select the entities for which I want to generate the class files.

Crist answered 25/1, 2010 at 22:7 Comment(2)
GREAT! That was exactly the solution. Thanks!Imray
It seems like this should be accessible via a right click or something.Flavorous
J
6

In Xcode 4, select the entity in the xcdatamodeld, then choose Editor Menu > Create NSManagedObject Subclass

Jaquesdalcroze answered 5/10, 2011 at 1:35 Comment(0)
G
3

If you are wanting to subclass NSManagedObject then I would highly recommend talking a look at mogenerator (github). It will autogenerate the subclasses for you AND keep them in sync as you update your model. It also has the concept of machine classes vs. human classes so that you can add convenience methods, etc. without your code being stepped on each time you update your model.

Gargantua answered 26/1, 2010 at 18:40 Comment(1)
mogenerator looks awesome. I had heard of it, but hadn't checked it out until now. Thanks!Crist
H
1

I've seen this problem before as well. Solution for me was to click on a non-data model file (in Groups & Files) and then click back on the versioned data model file (and entity within it) and then try File -> New File. Alternatively, restarting xcode, selecting the data model file (and entity within it) and then trying File -> New File also worked for me.

Holub answered 27/2, 2010 at 16:48 Comment(0)
L
0

Click On the top left where it says "Simulator 3.1.2 | debug". Change it to "IPHONE Device 3.1.2 (BASE SDK)... voila. (SAMS iphone in 24hrs?? lots of typos and incomplete procedures!)

Lordinwaiting answered 15/3, 2010 at 23:19 Comment(0)
G
0

Managed Object Class file template can be seen under "Core Data" section of new file creation option of XCode 4. The following screenshot depicts it.

NSManagedObject subclass template

Thanks, prodeveloper.

Ginni answered 7/1, 2013 at 6:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.