using Core Data, how would I list (i.e. return an NSArray of NSStrings) all the entity types that I have in my model?
such as Customer, Invoice, etc...
An entity describes an object, including its name, attributes, and relationships. Create an entity for each of your app's objects.
Specify that an entity is abstract if you will not create any instances of that entity. You typically make an entity abstract if you have a number of entities that all represent specializations of (inherit from) a common entity that should not itself be instantiated.
Still inside the Core Data editor, go to the Editor menu and choose Create NSManagedObject Subclass. Make sure your data model is selected then click Next. Make sure the Commit entity is checked then click Next again.
You can get the names from the model's entity descriptions:
NSArray *entityNames = [[myManagedObjectModel entities] valueForKey:@"name"];
or perhaps just:
NSArray *entityNames = myManagedObjectModel.entities.name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With