I have a relationship in a Core Data model that feels like it wants an association class. Specifically, I have a Person object, and a Location object. There is a many-to-many relation between these two classes, which has some properties, such as how many hours this person wishes to work at this location per week.
How do I model this using Core Data? A simple association between the two is part of the picture, but creating a new class which has the required properties as attributes, and then has a relationship to each of the other classes just doesn’t feel quite right – for instance it allows for a relationship to not have the desired properties.
Am I missing something, or is this the best way to model this type of relationship?
From your question, it’s not clear to me what constraints the model you propose can’t handle. You can require that all of the properties of the association class be non-nil and that the relationship (to-one to a Person with a to-many return) and to-one (again with a to-many return) to a Location be non-nil. This requires that any association created has a Person and a Location and the desired association properties.