Reputation: 3389
My application downloads posts from a server and stores them in Core Data. Since there are different types of posts I made a class "Post" that handles the basic properties of a post and subclassed it for every post type. That means that there are about 5 different post classes. Now I need to store them in CoreData as a relationship.
What's the proper way to do that? I can't subclass Core Data entities and I need to set a specific destination of the relationship.
I hope you understand my question. Thank you in advance.
Upvotes: 0
Views: 173
Reputation: 6325
What you can do is create a parent entity called like "Post" and have separate entities for each type of post and you set the post entity as it's parent entity. This creates the subclassing so that each child has all the properties and methods of the parent entity. You can also set the Parent as abstract so it basically acts as an interface.
Upvotes: 1