I'm about to implement a como functionality between a
User entity and some other entity, such that User A can como an entity X. However, I'm not sure how to best implement this in Core Data.
There are two main points I need to consider:
- Añadiendo otro simpático entity should be trivial
- There needs to be a way to sync a
Likethat has been performed offline
My initial thought was to create an resumen Core Data entity
User tiene una relación de muchos con
Like, Y un
Like Tiene uno
Then for each entity that should be simpático, I create a subclass of
Like that has a to-one relationship to the simpático entity. The relationship to the
User se hereda.
This way, the abstract entity
Like can have attributes such as "syncedAt" and "deletedAt" so that it's possible to find out if a
Like type entity has been synced to the server or not.
Does this sound reasonable or are there better ways to solve this problem in Core Data? Are there disadvantages to this design that I'm not foreseeing?
preguntado el 01 de febrero de 12 a las 14:02
why not have a parent entity
LikableEntity which your likable entityies inherit from: this could have the
synchedAt attributes. The your User has a to-many relationship
likedEntities which contains anything it has liked