How to get a list of existing objects (tables) in the master data

How to get a list of existing objects (tables) for a particular schema (managed object model) in the master data. I just started to introduce the concept of basic data and stuck to these points, please help

something like: SELECT COUNT (*) FROM information_schema.tables WHERE table_schema = 'dbName';

thanks

+8
ios6 core-data
source share
1 answer

You should read the Apple Core Programming Guide . To get objects for a specific NSManagedObjectModel , you must use one of the following (this assumes you have an NSManagedObjectModel named objectModel ):

 NSArray *myEntities = [objectModel entities]; // Array of all entities in the model 

or

 NSDictionary *myEntities = [objectModel entitiesByName]; // Dictionary of entities in the model, with the entity names as keys 

You can read more at NSManagedObjectModel Class Reference .

It seems you are coming from SQL background (like me). There are a number of concepts in Core Data that differ from each other - sometimes for the better, as soon as you understand them, sometimes it takes more work than a simple SQL statement that you can get used to. I think it’s important to approach Core Data without the SQL “baggage” and treat it as if you are learning to use a database for the first time - this will help to avoid disappointment.

+6
source share

All Articles