Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically Creating A Core Data Model At Runtime

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?

like image 484
motionpotion Avatar asked Apr 21 '13 13:04

motionpotion


1 Answers

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/

like image 153
Jody Hagins Avatar answered Sep 19 '22 21:09

Jody Hagins