I am trying to get the value of "@type" key in the following NSDictionary named 'robotDesign'
robotDesign : {
"@id" = "2";
"@type" = "piggyDash";
turnAngle = "-90";
width = "90.0";
}
that is a part of a JSON object I got using
[NSJSONSerialization JSONObjectWithData: options: error:];
I am using following code to extract @type value
NSString * robot_type = (NSString*)[robotDesign valueForKey:@"@type"];
but recive following error:
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<__NSCFDictionary 0x71de9e0> valueForUndefinedKey:]: this
class is not key value coding-compliant for the key type.'
NOTE: Please note that other objects in dictionary like 'turnAngle' and 'width' are extracted easily using same code given above but with their respective keys.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…