0

I have an app where i can search for a room to book it.

In my first view I can select a city and the street. In the second view I can select some attributes (like wlan, tv...)

In the 3rd view are the rooms that are available to the selection.

When I don't select an attribute, it should show me all the rooms that are available for the selected street/city.

Here is my predicate so far:

   NSPredicate *predicate =
[NSPredicate predicateWithFormat:
 @"((raumattribute.schalter CONTAINS YES) AND\
 (strasse.checks CONTAINS YES OR strasse.standort.ortcheck CONTAINS YES)) \
 OR\
 ((raumattribute.schalter CONTAINS NO) AND\
 (strasse.checks CONTAINS YES OR strasse.standort.ortcheck CONTAINS YES))"];

The problem is, i can't filter the rooms anymore with the attributes. When I select the city and go to the rooms, I can see all the rooms in the city. But as soon as I select an attribute it doesn't filter the rooms, but shows all the rooms in the selected city.

When I write my predicate like this:

 NSPredicate *predicate =

[NSPredicate predicateWithFormat:
 @"((raumattribute.schalter CONTAINS YES) AND\
 (strasse.checks CONTAINS YES OR strasse.standort.ortcheck CONTAINS YES)) 

I can filter the rooms with the streets and the attributes. .But when no attribute is selected, I can't see any room in the selected street.

here is a Screenshot of my updated schema: Screenshot

Eray Geveci
  • 1,099
  • 4
  • 17
  • 39

1 Answers1

0

You are mistaking the core-data framework, which is an object graph, with an SQL database substitute. This can be debated ad nauseam so let's not get into a philosophical discussion.

The proper way to do this from your problem description is to filter the rooms by street and then iterate through the result to exclude those that do not have the checked attributes. The resulting array could be the datasource of your resulting table.

However, from your code examples and the German entity and attribute names I am observing, it seems that you should perhaps consider revising your data structure. If you edit your question and also post your data model scheme I can give you further comments.

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • The screenshot is not complete. Very confusing. For fixing the display bug, see [this post](http://stackoverflow.com/questions/10026349/xcode-data-model-problems-with-appearance-in-editor/10028027#10028027). – Mundi Apr 05 '12 at 11:53