微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决从字典中的数组中检索元素

| 我是目标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数组作为键。如何检索特定键在数组中存储的信息? 提前致谢。     

解决方法

        如果要基于键检索信息,则将其存储在字典中,而不是首先存储在数组中。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。