Getting NSEntityDescription relationships

139 Views Asked by At

I have a core data model like so:

SALES_REP <--->> CUSTOMER <---->> PURCHASE_AGREEMENT <<------->> PRODUCTS

I can get the entity description for the Purchase Agreement and I can get the relationships (toCustomer and hasProducts)

[NSEntityDescription relationshipsByName];

but is it possible to get the Sales_Rep as well or do I have to pull that through the CUSTOMER entity?

Thanks

1

There are 1 best solutions below

1
On

According to your diagram, SALES_REP isn't directly related to PURCHASE_AGREEMENT, it's only linked via CUSTOMER. That means SALES_REP doesn't know anything about PURCHASE_AGREEMENT on its own. So yes, you'll have to move on to the entity description for CUSTOMER and ask it for its relationshipsByName. I'm not sure what you're trying to do here, but it would be easy to recursively look up relationships on an entity, then its related entities, and their related entities, etc, until you don't find any new ones.