NSManagedObjectModel - 动态创建模型 [英] NSManagedObjectModel - create model dynamically

查看:102
本文介绍了NSManagedObjectModel - 动态创建模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能指点我在Xcode中动态构建核心数据模型的教程吗?
我发现的所有教程都基于静态设计,但苹果文档说可以以编程方式构建模型。在Apple文档集中没有任何示例。

Can anyone point me to a tutorial on building the core data model dynamically in Xcode? All tutorials I found are based on a static design but the apple documentation says it is possible to build the model programatically..sadly no example on that in apple documentation set.

推荐答案

您必须初始化 NSManagedObjectModel ,然后为模型中的每个实体创建 NSEntityDescription ,然后为每个属性创建一个 NSAttributeDescription 。你可以在这篇文章中看到一个基本的例子。

You have to init a NSManagedObjectModel, then for each entity in your model you create an NSEntityDescription, then create an NSAttributeDescription per attribute. You can see a basic example from this post.

http://iphonedevsdk.com/forum/iphone-sdk-development/45944-want-to-create-a- parent-entity-programmatically-in-manegedobjectmodel.html

这篇关于NSManagedObjectModel - 动态创建模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆