iPhone - 合并 NSArray 中的键 (Objective-C)
我在数组和键方面遇到了麻烦...我的数据库中有一个数组:
NSArray *elementArray = [[[menuArray valueForKey:@"meals"] valueForKey:@"recipe"] valueForKey:@"elements"]
这里的问题是我希望将我所有菜单的所有餐食的所有元素都放在一个数组中,这样: [elementArray objectAtIndex:0] = 我的第一个元素 等等...
在上面的示例中,元素由键分隔。 我怎样才能得到它?
希望它足够清楚......
谢谢
I'm having troubles with arrays and keys... I have an array from my database:
NSArray *elementArray = [[[menuArray valueForKey:@"meals"] valueForKey:@"recipe"] valueForKey:@"elements"]
The problem here is that I would like all my elements of all my meals of all my menus in an array such that:[elementArray objectAtIndex:0] = my first element
etc...
In the example above, the elements are separated by the keys.
How can I get that?
Hope it's clear enough...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的代码片段来看,我不清楚您的数据的结构,但我认为它类似于拥有
NSArray 的
并希望将所有NSDictionary
(称为aDictionary
)NSArray
合并为一个。如果是这种情况,那么:(此代码尚未经过测试。)
From your code snippet, it is not clear to me exactly how your data is structured, but I think it's analogous to having an
NSDictionary
(calledaDictionary
) ofNSArray
and wanting to combine all theNSArray
into one. If this is the case, then:(This code has not been tested.)