In JSON parse, save the parsing data into NSDictionary,
And read the key-value like:
NSString *verCode = [JSONDict objectForKey:@"v"];
but sometime, the key-value is other format, the program will crash, so I need covert to stringValue;
like this:
NSString *verCode = [[JSONDict objectForKey:@"v"] stringValue];
How can I catch exception in iOS program?
You can use @try{ } around code to catch exceptions.
In your case though a better approach is to look at the types of the object in the array for a key and use the right conversion as needed: