ios - Add to cart functionality - Core data -
i trying create best possible design following scenario.
category -> list of products
in tableview list of products shown, user has option add product cart.
so, whenever user opens cart, can see of products has added.
my question how can best setup functionality in core data? best solution maintain separate cart entity? or relationship right way it?, if yes can please tell me kind relationship should between cart & product?
make cart
entity suggested to-many relationship cartproduct
entity. cart
entity can contain 'meta' information purchase , cartproduct
link actual product
entity.
the type of relationship between cartproduct
entity , product
entity 1-1, in xcode, in data model editor, cartproduct
entity selected, sure add product
entity relationship in relationships section , leave to-many relationship setting unchecked. values this:
- relationship: product
- destination: product
- inverse: cartproduct
then, select product
entity in editor , double check relationship exists looks (again, make sure to-many relationship setting unchecked):
- relationship: cartproduct
- destination: cartproduct
- inverse: product
the above should started.
Comments
Post a Comment