I want to have this model :
Feat开发者_StackOverflow中文版ure -> Image (relationship name: image inverse: feature)
Feature -> Image (relationship name: thumb inverse: feature)
Image -> Feature (relationship name: feature inverse: ????)
I can setup only one inverse. But it looks that i need both: image
and thumb
UPDATE
One of the way is to create this model:
Picture has all that we need from Image Image inherit picture Thumb inherit picture
they share NSManagedObject Class.
Is this correct?
UPDATE 2
After @StuDev help my model looks like.
Thanks.
I would recommend setting up a model that looks something like this:
So using your notation:
Feature -> Image (destination: Image, inverse: feature)
Feature -> Thumb (destination: Thumb, inverse: feature)
Or, the other way around (the same thing really):
Image -> Feature (destination: Feature, inverse: image)
Thumb -> Feature (destination: Feature, inverse: thumb)
This way you keep access to your thumb and image separate, so you only need to load the one you need at that time. You shouldn't have a need to store the image and thumb within the same entity (correct me if I'm wrong...), so this setup keeps things nice and clear.
EDIT
Alternatively, if you would like to keep the image and thumb within the same NSManagedObject
subclass (as you suggest in your update), then combine these as attributes within an entity "Picture" (or whatever you want to call it):
Using this approach, when you want to access either the image or thumbnail of a given feature, simply fault to the feature's picture, and then access the image or thumb:
UIImage *theThumbnail = [feature.picture thumb]; // Assuming you are storing the image & thumb as a transformable (UIImage) type
精彩评论