简体   繁体   English

从字典中的数组中检索元素

[英]Retrieve elements from an array in a dictionary

I am new to objective C and I really need help with the following problem.我是目标 C 的新手,我真的需要帮助解决以下问题。 I have a dictionary userDetails which contains array userAttributes我有一个字典 userDetails 包含数组 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.其中 myArrayOne 是一个包含所有信息的字符串数组。 I am using employeeID array as key.我使用employeeID 数组作为键。 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.如果要根据键检索信息,首先将其存储在字典而不是数组中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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