NSArray 来自 NSDictionary 中的数组
我有一个从远程 PList 加载的 NSDictionary。 它包含一个字典数组:
(
{
id = "1234";
count = "45";
},
{
id = "244";
count = "89";
},
{
id = "9909";
count = "123";
}
)
如何将其放入 NSArray 中?我不希望每个键都有单独的数组。 我只想要一个 NSDictionary 的 NSArray 。
可能有一个简单的答案,但这一直困扰着我。
谢谢
I have a NSDictionary loaded from a remote PList.
It contains an array of dictionaries:
(
{
id = "1234";
count = "45";
},
{
id = "244";
count = "89";
},
{
id = "9909";
count = "123";
}
)
How do I get this into an NSArray? I don't want separate arrays for each key.
I just want an NSArray of NSDictionary.
There is probably a simple answer, but this has been bugging me.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你说你有一本包含数组的字典。无论数组的键是什么,只需询问 do
[dictionary objectForKey:theKey]
,您就会得到该数组。编辑:从你的评论来看,听起来你只是有一个 NSArray,它根本不在 NSDictionary 中。如果是这样,那么您已经拥有了您正在寻找的东西。
You say you have a dictionary containing the array. Whatever the key for the array is, just ask do
[dictionary objectForKey:theKey]
, and you'll have the array.EDIT: From your comments, it sounds like you just have an NSArray which is not in an NSDictionary at all. If so, you already have what you are looking for.
怎么样:
请注意,这是已弃用的 plist 格式(现在首选 XML 或二进制格式)。
How about:
Note that this is a deprecated plist format (XML or binary format is now preferred).
你尝试过[字典objectAtIndex:0]objectAtIndex:0]吗?尝试在外循环中迭代 objectAtIndex。
一切顺利。
have u tried [dictionary objectAtIndex:0]objectAtIndex:0]. try iterating over objectAtIndex in the outer loop.
all the best.