سؤال

{ 
ErrorCodes = ( 
   12 
); 
Success=0; 
}

I have json response like above and i am want to fetch 12 from error code so that i can display appropriate error message. I am doing like this

NSInteger err = [[dict objectForKey:@"ErrorCodes"] integerValue]; 

but this is giving exception error like

[__NSArrayM integerValue]: unrecognized selector sent to instance

what am i doing wrong? and how can i convert error code 12 into NSInteger...

هل كانت مفيدة؟

المحلول

ErrorCodes here is an array, and that is the reason you got the error. You should try something like this instead:

[[[dict objectForKey:@"ErrorCodes"] objectAtIndex:0] integerValue];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top