For example I have data model like this
Entity: Store Entity: Inventory Entity:Product
Attribute: name Attribute: qty Attribute: name
Relationship: inventories <---->> Relationsips: <<----> Relationship: inventories
stores
products
I wanna know how retrieve from Core Data list of Stores for exact Product.
I have tableView with products and on click on exact product cell I wanna move to another controller with list of stores which contatins this product.
As I understand I can get NSSet of all Inventory entities first and iterate it to fetch stores. But I think Core Data is more intelligent thing and more simple and elegant method exists for it. For example, maybe when I get all inventory objects I can fetch Store with predicate somethink like this “Store.inventories IN (array of my inventories from previous fetch)”. Or even more simple way. Thanks!
With Core Data – as a general rule – when you have a managed object in your hands, start with that object and navigate the model to retrieve related entities. Specifically: