是否可以编程生成核心数据结构? [英] Is it possible to generate a Core Data structure programatically?
问题描述
我目前正在开发一个项目,可能需要能够从描述每个对象,它的属性和关系的JSON feed自动生成一个核心数据模型和类。这将使我们公司能够在每个项目开始时从我们的CRM中快速生成一个工作核心数据库。
I am currently working on a project which may require the ability to generate a Core Data model and classes automatically from a JSON feed which describes each object, it's properties and relationships. This would enable our company to quickly generate a working core data database from our CRM at the start of each project.
这是否可以/容易实现?如果是这样,有没有人有任何提示,我可以从哪里开始?
我已经创建了使用Core Data的各种iOS应用程序,但是我从来没有创建过需要自动创建Core Data模型的iOS应用程序。
Is this possible/easy to achieve? If so, does anyone have any tips on where I can get started? I have already created various iOS apps which use Core Data but I have never made one which needs to automatically create a Core Data model.
推荐答案
是的,您可以动态创建Core Data模型。可以创建 NSManagedObjectModel
而不使用存储模型, NSEntityDescription
/ NSAttributeDescription
实例可以在传递给 NSPersistentStoreCoordinator
之前定义和添加。 Apple有一个例子,在核心数据实用教程。
Yes, you can create a Core Data model dynamically. An NSManagedObjectModel
can be created without a stored model, and NSEntityDescription
/NSAttributeDescription
instances can be defined and added to it before being passed to an NSPersistentStoreCoordinator
. Apple has an example of doing this in their Core Data Utility Tutorial.
这篇关于是否可以编程生成核心数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!