开发者

Retrieving Relationships from within two arrays of pointers

开发者 https://www.devze.com 2022-12-23 05:11 出处:网络
In a portion of a program I\'m working on, I need to count all the times each person ha开发者_如何学JAVAs worked on projects with each other person.Let\'s say we have \"Employee\" entities and \"Sessi

In a portion of a program I'm working on, I need to count all the times each person ha开发者_如何学JAVAs 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 * superList;

EDIT: I forgot to represent this array that points to the controller's arrangedObjects.

NSArray * list = [superList arrangedObjects];
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?


Based on your line:

NSArray *A = [[list objectAtIndex:x] valueForKey:@"projectAs"];

The call:

[list objectAtIndex:y]

does not return an array - it returns a NSDictionary, which means you cannot call objectAtIndex:z on the result.

It appears this should be [masterlist objectAtIndex:y] ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号