开发者

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

开发者 https://www.devze.com 2022-12-17 07:42 出处:网络
开发者_如何学CI 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 Cl
开发者_如何学C

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?


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


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


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.


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.


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!)


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.

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

Thanks, prodeveloper.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号