I need to store an activity feed in an iOS application. Activity feed items will have a payload
field which can be one of many (and I really mean many) types of entities in the system.
What is a good way to implement this payload
relationship field on the Activity
entity in my CoreData model?
Is it possible to use the id
data type, or maybe use an NSManagedObject
type?
One way to workaround this maybe to just store CoreData's entityId as a string in a special field, but I'd rather avoid that if there is a better way.
Example:
For simplicity let's say we have a not-so-standard blogging model: User
, Blog
, BlogPost
, Comment
and the following activities may happen:
- User may create a new blog.
- User may publish a new blog post.
- A blog can be commented on.
- A comment maybe liked.
- etc.
Each of these generate a new Activity
item on the website which in turns have a related payload
relation to the item that was modified or being acted on.
Now I need to download, translate and store these activity feed items from the website in my iPhone application... so how do I mimic this payload
field since it maybe pointing to any possible entity?
In my real code, though, there are about 10+ types of entities that could be put into this payload
field so I'm looking for a good approach here.