从字典中的数组中检索元素
我是目标 C 的新手,我确实需要帮助解决以下问题。我有一个字典 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]);
}
,其中 myArrayOne 是包含所有信息的字符串数组。我使用employeeID 数组作为键。如何检索存储在数组中的特定键的信息? 提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想根据键检索信息,请首先将其存储在字典中而不是数组中。
If you want to retrieve information based on a key, you store it in a dictionary rather than an array in the first place.