嵌套字典-定位单个键

| 我很高兴在这里有很多这类问题,但是我找不到可行的答案。 简而言之,我需要获取选定类别中所有产品的价格数组。 这是我的pList:
<key>Product Category</key>
    <dict>
        <key>Product 1</key>
        <dict>
            <key>Image</key>
            <string></string>
            <key>Large Image</key>
            <string></string>
            <key>Detail</key>
            <string></string>
            <key>Price</key>
            <integer>100</integer>
        </dict>
        <key>Product 2</key>
        <dict>
            <key>Image</key>
            <string></string>
            <key>Large Image</key>
            <string></string>
            <key>Detail</key>
            <string></string>
            <key>Price</key>
            <integer>200</integer>
        </dict>
    </dict>
我不知道如何在这样的层次结构中定位目标。到目前为止,这是我的尝试:
NSString *detailPListPath = [[NSBundle mainBundle] pathForResource:@\"detail\" ofType:@\"plist\"];
NSDictionary *detailDictionary = [NSDictionary dictionaryWithContentsOfFile:detailPListPath];
currentDetail = [[NSMutableArray alloc] init];

for (id object in [detailDictionary objectForKey:indication]) {
    [currentDetail addObject:object];
}
但是then2ѭ仅显示产品1,产品2等。 谢谢你的尽心帮助!     
已邀请:
           currentDetail只是显示   产品1,产品2等 由于
NSDictionary
的快速枚举会遍历键,因此需要将键添加到数组中。因此,您的输出显示产品1,产品2等。   我需要获取一系列价格   所选类别中的所有产品。 您需要使用以下键(产品1,产品2等)来检索关联的产品字典,然后检索与价格键关联的值:
NSDictionary *detailDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@\"detail\" ofType:@\"plist\"]];
NSDictionary *categoryDict = [detailDict objectForKey:@\"Product Category\"];
NSMutableArray *pricesArray = [NSMutableArray arrayWithCapacity:[categoryDict count]];
for (NSString *key in categoryDict) {
    [pricesArray addObject:[[categoryDict objectForKey:key] objectForKey:@\"Price\"]];
}
请记住,结果
pricesArray
没有特定顺序。     

要回复问题请先登录注册