Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Producing different result when only one object is shown upon request #14

Open
bahiamartins opened this issue Nov 11, 2015 · 1 comment

Comments

@bahiamartins
Copy link

I have an object c code connecting to a web server returning an xml.
after, I put the result into an NSDictionary:

self.xmlDictionary = [XMLReader dictionaryForXMLString:self.theXML options:XMLReaderOptionsProcessNamespaces error:&parseError];
NSLog(@"%@", self.xmlDictionary);

If my JSON returns more than 1 object my code counts the objects perfectly. But if my JSON returns only ONE object it miscounts.

My guess is the parenthesis are not inserted when only one value is returned.

Check my stack with complete code please:
http://stackoverflow.com/questions/33659623/objective-c-miscounting-array-with-json

@bahiamartins
Copy link
Author

Just found that I needed to insert this code:

if (![list isKindOfClass:[NSArray class]])
{
// if 'list' isn't an array, we create a new array containing our object
list = [NSArray arrayWithObject:list];
}

And when the array has only one object, everything works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant