I'm using Coredata and have a Data Model with the following toMany relationships: Rooms.isUsedBy -> Class many classes use a Room Class.hasStudents -> Students many Students are in a Class
Given the Room I want to get all of the students that use the room. Here is the simplified code:
-(void) studentsinRoom:(Room*)aRoom { NSSet* roomStudents = [[NSSet alloc]init]; for (SchoolClass* aClass in aRoom.isUsedBy) { roomStudents = [roomStudents setByAddingObjectsFromSet:aClass.hasStudents]; } [roomStudents release]; }
roomStudents is computed correctly.
However when exiting the method I get a “EXC_BAD_ACCESS” error.
I'm debuggin this in the iPhone Simulator.
I'm pretty sure that I'm doing/not doing something correctly with the memory management. I do have a break set on "malloc_error_break" and it is not being hit.