1

I am working on iOS library project that requires Core Data framework in order to store data. To avoid bundling data model file with library I'd like to generate it dynamically with code.

Are there any code generators that can take some xml/json/yaml model description file on input and produce model construction code and NSManagedObject subclasses on output?

Alex
  • 79
  • 4
  • I used RestKit in projects before but I don't see any code generators there. – Alex Nov 15 '13 at 08:18
  • maybe I misunderstood your question, to map json to NSmanagedObjects i use KVO. it works quite well. Btw I'm not sure you can dynamically change the data model – Nicolas Manzini Nov 15 '13 at 08:22
  • No, object mapping is not the problem for my case. I am looking for some code-generator for NSManagedObjectModel creation code [like this](http://stackoverflow.com/questions/17288607/nsmanagedobjectmodel-create-model-dynamically) – Alex Nov 15 '13 at 08:26
  • You typically create managed object models using the data modeling tool in Xcode, but it is possible to build a model programmatically if needed. My bad. Indeed it must be possible seems actually cool stuff. But I don't know – Nicolas Manzini Nov 15 '13 at 08:29
  • Anyway thanks. If I won't be able to find such tool soon I'll try to write it myself. – Alex Nov 15 '13 at 08:37

1 Answers1

0

You do not need a tool for creating NSManagedObject models in code. There is a full API available from Apple in Objective-C. Check out these documentation sources.

NSManagedObjectModel
NSEntityDescription
NSAttributeDescription

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • I know that there is API for dynamic NSManagedObjectModel management, but writing and maintaining all the code for creating model and managed object subclasses for this model by hands will be much slower and will produce more errors. – Alex Nov 15 '13 at 10:40