Need help in Objective C count JSON objects.
I'm using github.com/amarcadet/XMLReader/ to read my XML.
If my JSON returns more than 1 object my code counts the objects perfectly. But if my JSON returns only ONE object it miscounts.
Here is my JSON with 2 objects:
QuestionTotal = {
Question = ({
Description = {
text = "bla bla";
};
id = {
text = "123";
};
ord = {
text = 1;
};
}, {
Description = {
text = "blu blu";
};
id = {
text = "456";
};
ord = {
text = 2;
};
});
};
My objective c code:
NSDictionary *xmlDictionary;
NSMutableArray *questions = [[[[[[[self.xmlDictionary objectForKey:@"Envelope"] objectForKey:@"Body"] objectForKey:@"GetInterviewResponse"] objectForKey:@"GetInterviewResult"] objectForKey:@"Obj"] objectForKey:@"QuestionsTotal"] objectForKey:@"Question"];
NSLog(@"Total questions: %lu", (unsigned long)[questions count]);
The code above return Log: Total questions: 2
If JSON is:
QuestionTotal = {
Question = {
Description = {
text = "bla bla";
};
id = {
text = "123";
};
ord = {
text = 1;
};
};
};
The code returns Log: Total questions: 3 Which is wrong.