I have this code:
NSDictionary *jsonGuardado = [self dictionaryFromJson:JSON];
NSLog(@"HOLA %@",jsonGuardado);
NSMutableArray *arrayCodigos = [jsonGuardado objectForKey:@"code"];
codigos = arrayCodigos;
(Codigos is an NSMutableArray)
The NSLOG return this:
HOLA (
{
code = 22051310;
},
{
code = 22051311;
},
{
code = 22051312;
},
{
code = 22051313;
}
)
But right after this, a message error says:
-[JKArray objectForKey:]: unrecognized selector sent to instance
I search this error in Google and here and all the questions I found not help me.
I'm using the JSONKit for make the dictionaryFromJson method.
You try this,
NSArray *jsonGuardado = [self dictionaryFromJson:JSON];
NSLog(@"HOLA %@",jsonGuardado);
NSMutableArray *arrayCodigos = [NSMutableArray arrayWithArray:[jsonGuardado valueForKey:@"code"]];
NSLog(@"arrayCodigos %@", arrayCodigos);
It will print only values.
The parser returns an array and not a dictionary in your case.
[self dictionaryFromJson:JSON] returns a Json array but you are capturing it in NSDictionary
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With