简体   繁体   中英

Retrieve elements from an array in a dictionary

I am new to objective C and I really need help with the following problem. I have a dictionary userDetails which contains array userAttributes

 int y=0;
 for (int z=0;z<noOfNeighbours;z++) {
NSMutableArray *userAttributes = [userDetails objectForKey:[employeeID objectAtIndex:z]];
            [userAttributes addObject:[NSString stringWithFormat:[myArrayOne objectAtIndex:17+y]]];
            [userAttributes addObject:[NSString stringWithFormat:[myArrayOne objectAtIndex:18+y]]];
            [userAttributes addObject:[NSString stringWithFormat:[myArrayOne objectAtIndex:22+y]]];
             y=y+17;
            //NSLog(@"%@",[userAttributes objectAtIndex:0]);
    }

where myArrayOne is a string array containing all the information. I am using employeeID array as key. How do I retrieve the information stored in the array for a particular key?? Thanks in advance.

If you want to retrieve information based on a key, you store it in a dictionary rather than an array in the first place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM