[英]NSArray from array in NSDictionary
I have a NSDictionary loaded from a remote PList. 我有一个从远程PList加载的NSDictionary。 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? 我如何将其纳入NSArray? I don't want separate arrays for each key.
我不希望每个键都有单独的数组。 I just want an NSArray of NSDictionary.
我只想要一个NSDictionary的NSArray。
There is probably a simple answer, but this has been bugging me. 可能有一个简单的答案,但这一直困扰着我。
Thanks 谢谢
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. 无论数组的关键是什么,只要问
[dictionary objectForKey:theKey]
,你就会拥有数组。
EDIT: From your comments, it sounds like you just have an NSArray which is not in an NSDictionary at all. 编辑:从您的评论,听起来你只是有一个NSArray根本不在 NSDictionary。 If so, you already have what you are looking for.
如果是这样,你已经拥有了你想要的东西。
How about: 怎么样:
NSArray *dicts = [NSPropertyListSerialization propertyListWithData:data
options:0
format:NSPropertyListOpenStepFormat
error:NULL];
Note that this is a deprecated plist format (XML or binary format is now preferred). 请注意,这是一种不推荐使用的plist格式(现在首选XML或二进制格式)。
have u tried [dictionary objectAtIndex:0]objectAtIndex:0]. 你试过[dictionary objectAtIndex:0] objectAtIndex:0]。 try iterating over objectAtIndex in the outer loop.
尝试在外部循环中迭代objectAtIndex。
all the best. 祝一切顺利。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.