IOS5.1 / XCode 4.3
I have 2 entities in my core data, lets call them Jobs and Workers, each Job has a Joiner, a Brickie, and a Plumber, these are fields which i want to relate to 3 different workers.
A Workers role is a text property that is populated from a pick list when the worker is created.
As the Workers don’t have specific Role fields, I’m unsure how to satisfy core data’s need for inverse relationships.
Any help would be appreciated, this is my first core data project and I’m not even sure if my model is appropriate for this kind of storage.
Thanks
Thanks for the quick and clear answer Matthias, Just to clarify, I will add new worker roles to the pick list in Xcode, the user won’t have that feature.
I considered option 1 but rejected it because of the work involved when adding a new role.
I like option 2 better, question: would the workers relationship in the job object be a collection of all workers associated with the job? and would the fetched properties be generated on the fly from the Role properties in that collection.
If i didn’t use the fetched properties would i need to iterate the workers relationship to find the plumber rather than having a direct link?
this site won’t let me add comments to answers or even my own question, so I’ve had to put a response here 🙁
Option 1: Create a different entity for each worker. They could all have a parent entity like Worker where you would put common attributes.
Option 2: Add a role attribute to the worker. You could create fetched relationships to get the different kind of workers.
If you want it dynamic (e.g. in the year 2525 somebody uses your app and he needs a technician to install a teleportation device) choose option 2. But then without fetched relationships.