无法访问字典中的对象

时间:2013-02-28 21:37:43

标签: ios objective-c indexing nsarray nsdictionary

我在另一个NSDictionary中遇到NSDictionary时遇到问题。我一直在尝试访问关键nodeChildArray的第0个索引中的nodeContent键中的文本,“使用Facility的顾客数量:163”。这是阵列。

{
nodeAttributeArray =     (
            {
        attributeName = class;
        nodeContent = style1;
    }
);
nodeChildArray =     (
            {
        nodeContent = "Number of Patrons Using Facility: 163";
        nodeName = text;
    },
            {
        nodeName = br;
    },
            {
        nodeContent = "
        Room Occupancy: 210 ";
        nodeName = text;
    },
            {
        nodeName = br;
    },
            {
        nodeContent = "
        Current Wait: 0 minutes ";
        nodeName = text;
    }
);
nodeName = p;
}

我尝试了以下不同的变体:

//I Parse some HTML using Xpath before this
NSArray *tutorialsNodes = [tutorialsParser    
searchWithXPathQuery:tutorialsXpathQueryString];

NSDictionary*dict=[tutorialsNodes objectAtIndex:0];
NSDictionary*dict2=[[dict objectForKey:@"nodeChildArray"]objectAtIndex:0];

所以它应该返回索引中的两个键,但它一直返回null。我真的很感激一些帮助。谢谢!

1 个答案:

答案 0 :(得分:0)

MainResultDictionary =>其中包含您的回复

你应该编码

NSArray *dictsArr = [MainResultDictionary objectForkey:@"nodeChildArray"];
NSdictionary *dict = [dictsArr objectAtIndex:0];
[dict objectForkey:@"nodeContent"];