在运行时动态创建核心数据模型 [英] Dynamically Creating A Core Data Model At Runtime

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

问题描述

在运行时可以从服务器上的一组实体生成核心数据模型吗?例如SharePoint列表或SQL / MySQL / Parse。



我试图去一个动态路由,因为SharePoint列表/ SQL / Parse中的字段可以随时添加未来意味着应用程序中的核心数据模型版本必须更改以匹配服务器上的SharePoint列表。如果可以动态生成核心数据中的实体(SharePoint列表),那么当实体中的列在服务器上更改时,应用程序不会断开。



如果任何人都有一个例子。

解决方案

请参阅NSEntityDescription的参考。您可以通过在代码中定义实体来构建模型定义。



https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSEntityDescription_Class/NSEntityDescription.html



编辑



从我们在Cocoanetics的好朋友: http://www.cocoanetics.com/2012/04/creating-a-coredata-model-in -code /


Is it possible at runtime to generate a core data model from a set of entities on a server? e.g. SharePoint lists or SQL/MySQL/Parse.

I'm trying to go a dynamic route because fields in SharePoint lists/SQL/Parse may be added at any time in the future meaning the core data model version in the app has to change to match the SharePoint list on the server. If it was possible to generate an entity (SharePoint list) in core data dynamically then the app won't break when the columns in the entity change on the server.

If this is possible does anybody have an example?

解决方案

See the reference for NSEntityDescription. You can build up a model definition by defining entities in code.

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSEntityDescription_Class/NSEntityDescription.html

Edit

From our good friends at Cocoanetics: http://www.cocoanetics.com/2012/04/creating-a-coredata-model-in-code/

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

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