I would like to know how to retrieve an array from within a dictionary and then retrieve the dictionary from the array object.
i’m following this http://ios.biomsoft.com/2011/09/11/simple-xml-to-nsdictionary-converter/
itemDict
(
{
postID = {
text = 26;
};
score = {
text = 20;
};
title = {
text = "http://www.google.com quiz";
};
url = {
text = "http://www.google.com";
};
},
{
postID = {
text = 27;
};
score = {
text = 10;
};
title = {
text = "http://www.google.com";
};
url = {
text = "http://www.google.com";
};
},
{
postID = {
text = 3;
};
score = {
text = 41;
};
title = {
text = "http://www.google.com";
};
url = {
text = "http://www.google.com";
};
},
{
postID = {
text = 35;
};
score = {
text = 10;
};
title = {
text = "Sample Video";
};
url = {
text = "http://www.google.com";
};
},
{
postID = {
text = 43;
};
score = {
text = 30;
};
title = {
text = "sample";
};
url = {
text = "http://www.google.com";
};
}
)
Alrighty, what you want to do is the following.
From what I can gather from the link posted as well, you have a top level
NSDictionarywhich then contains the XML inside it. There would be an object inside theNSDictionarywhich would, from your example, beitemDictbut that, to my eyes, looks more like an NSArray.From here, I’d store that
NSArrayinside another one.Each object inside that array is an
NSDictionaryof keys and objects matched to them. Obviously I’m talking about this bit.Maybe something like the following will let you dive down deep enough.
That code should show the output of each NSDictionary inside the NSArray. From here it is a simple case of doing whatever you want with the NSDictionary.
EDIT
Just had another look and thought I’d add this in as well.
It seems each NSDictionary we would make with the above code, then has a key for another object and that object is stored inside another dictionary. Something really weird with the XML if you ask me…
But, a work around could be the following.
If this isn’t what you’re wanting to do, please edit your question so I can rectify my response.
Hope that helps!