NSPredicate retrieve a certain object

I have a Building entity and a Floor entity. There is a one-to-many relationship between them. Building<---->>Floor

Building has an attribute called buildingName. I want to retrieve an NSArray with floor entities according to a certain buildingName.

I have tried different kind of predicates, but I cant get it right.


If you have a Building class with a floor NSSet in it you can simply use:

   Building *building = //get the building you need
   NSArray *building_floors = [building.floor allObjects];

If not, since floor has only 1 building, you can fetch the Floor entity with a predicate of the building name

   NSPredicate *predicate = [NSPredicate predicateWithFormat:@"building.buildingName == %@",building.buildingName];

(I assume that "building" is the name of the relationship in the Floor entity)

Need Your Help

Is there a way to force an object to be created on the heap with shared_ptr?

c++ c++11 stl heap

i was wondering if it is possible to force an object to be created on the heap by creating a private/protected desctuctor and by using shared_ptrs to ensure an automatic resource managment (the RAII

Is it correct to join the same table multiple times on different conditions?

sql styles

I'm building a simple app based on a moodle (2.4) database. The db is mysql 5.1.69