Luke Mcneice
Luke Mcneice

Reputation: 2720

Inverse relationship on Child's child

I'm trying to use core data relationships to make an an inverse relationship work between a child's child object.

Here is an example of what I'm trying to achieve:

I have a number of filing cabinets, each filing cabinet has number of drawers, each drawer has a number of files.

When I add a file to a drawer the drawer sets itself as the inverse on the file however, I want an automagic cabinet inverse on a a file too. So i can do something like [file cabinet] as well as the standard [file drawer] Right now, I can't create this particular inverse.

I know I could use [[file drawer] cabinet] but this is a simple example for my use case.

Upvotes: 0

Views: 81

Answers (1)

Paul.s
Paul.s

Reputation: 38728

Why not just add a method to your NSManagedObject subclass?

- (Cabinet *)cabinet;
{
    return self.drawer.cabinet;
}

Upvotes: 3

Related Questions