views:

121

answers:

1

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 Items 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!

+3  A: 

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.

Marcus S. Zarra
Brilliant, thanks. As for performance, I'm not too worried, there shouldn't be massive amounts of data in the app. I'll separate things out if it does become a problem.
Tim Sullivan