简体   繁体   中英

Convert existing object model to Core Data managed object model

I am developing an iOS app and have several object models. Now I want to convert them to core data managed objects, so creating the entities and attributes from the object instead of the standard opposite way of generating the objects from the model. What is the best way to accomplish this?

I tried extending from NSManagedObject instead of NSObject , then manually creating the entities and attributes and setting up the Class name for the entity but that didn't work :-(

Thanks

I recently did this for a big project with a very large and complex data model. Here is a workflow that I found to be very feasible.

First, I create a new data model in Xcode and populate it by hand. This is a very good exercise as it forces you to review your model and perhaps take advantage of simplification opportunities.

Then, generate your class files with Xcode from the model. If you have any special code that should be included in the objects, add them as categories in separate files (eg Event.h & Event.m generated by Xcode, Event+Additions.h & Event+Additions.m with your code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM