Question

I'm creating an application in which I have several entities and now I need to filter the content of third combobox dynamically. I explain myself better. I have 3 combobox (building, floor and department), I would like first to show me all the buildings included, but the second should show only selected before the plans for the building, the last I should be select only the departments of the building and the plan you choose. How can I do this? To simplify attaching some photos.

enter image description here

enter image description here

enter image description here

Was it helpful?

Solution

You simply drill down with predicates, if you use single fetch requests to Core Data.

However, your relationships are not set up correctly. For example, there is an edificio attribute in Particelle. If it refers to an building, it should be a relationship to a Edifici object, not some kind of foreign key. There are no foreign keys in Core Data, just relationships.

If you do this, everything becomes much easier by using a NSFetchedResultsController. You can now simply traverse the object graph without any specific fetching.

The scheme could be something like this (maybe need to change the order):

Anno <--->> Particella <---->> Edificio <---->> AreaRischio

Now you can simply tell the fetched results controller to start fetching all Anno entities. Then you drill down with simple dot notation:

NSSet *listForNextTable = selectedAnnoObject.particelle; 

and further with

NSSet *listForNextTable = selectedParticellaObject.edifici;

etc. You see, it gets really simple.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top