7

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?

4

1 回答 1

8

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/

于 2013-04-21T19:19:05.113 回答