Retrieving Relationships from within two arrays of pointers

Posted by DanF on Stack Overflow See other posts from Stack Overflow or by DanF
Published on 2010-03-19T08:48:40Z Indexed on 2010/03/19 8:51 UTC
Read the original article Hit count: 157

Filed under:
|
|

In a portion of a program I'm working on, I need to count all the times each person has worked on projects with each other person. Let's say we have "Employee" entities and "Session" entities. In each session, there are four project types, "A", "B", "C", & "D", each a many-to-many relationship to Employees.

I'm making a loop to systematically review every person a selected person has worked with. First, I put all their project types in a single array, so it's easier to loop through, but by the time I ask the last nested Project for its Employee members, I get an "unrecognized selector" error.

IBOutlet NSArrayController * list;
int x;
for(x = 0; x < [list count]; x++){
NSArray *A = [[list objectAtIndex:x] valueForKey:@"projectAs"];
NSArray *A = [[list objectAtIndex:x] valueForKey:@"projectBs"];
NSArray *A = [[list objectAtIndex:x] valueForKey:@"projectCs"];
NSArray *A = [[list objectAtIndex:x] valueForKey:@"projectDs"];

NSArray *masterList = [[NSArray alloc] initWithObjects: projectAs, projectBs, projectCs, projectDs, nil];

int y;
for(y = 0; y < [masterList count]; y++){
int z;
for(z = 0; z < [[masterlist objectAtIndex:y] count]; z++){
//And now to make an Array of this employee's partners on the selected object, to run comparisons on.
//I also have an array of keys for each session's teams, so that's what I'm referencing here:
NSArray * thisTeam = [list objectAtIndex:y] objectAtIndex:z] valueForKey:projectKey];

This throws an exception... namely, -[_NSFaultingMutableSet objectAtIndex:]: unrecognized selector sent to instance

What's wrong with that last Array creation?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa