Core Data: Inheritance, STI or otherwise?

core-data, iphone

Solution

You can create an Item abstract entity and then have each of your unique items extend from it. Keep the relationship in the abstract so that your Thing can see all of them.

Be warned, however, that under the hood, all of those children will actually be put into a single wide table so you will need to test for performance considerations.

Problem

I can't seem to find any information in the documentation or via Google on this, but if there is something, a pointer to it would be great. In my app, I have a `Thing` as a core data class. I intend to have that `Thing` contain many `Item`s which has a bunch of fields in it, like `order` and `created_date` and so forth. However, there are a variety of `Item` types, each with their own set of fields. Ideally, I'd like to create several subclasses of `Item`, so that I can access all the items together in a single array or something. In Rails, I'd use STI for this. Does Core Data support similar behaviour? Thanks!

Original source