I am trying to get the key value "@type" in the following NSDictionary named "robotDesign"
robotDesign : { "@id" = "2"; "@type" = "piggyDash"; turnAngle = "-90"; width = "90.0"; }
which is part of the JSON object that I used
[NSJSONSerialization JSONObjectWithData: options: error:]
I use the following code to retrieve @type value
NSString * robot_type = (NSString*)[robotDesign valueForKey:@"@type"];
but get the following error:
Application termination due to the uncaught exception "NSUnknownKeyException", reason: '[<__NSCFDictionary 0x71de9e0> valueForUndefinedKey:]: this class is not the key for encoding for the key type. ''
NOTE. Note that other objects in the dictionary, such as "turnAngle" and "width", are easily retrieved using the same code as above, but with the corresponding keys.
source share