I am hitting the error (stated in the subject) because there are times the property 'id' does not store the hash containing '$oid' in the returned json. For example
Sometimes I get:
"id":{"$oid":"4eea972209f47a0028000140"}
Some other times I get
"id":"4eea972209f47a0028000140"
I am trying to do a check in the following code to cater for such irregularity
if ([[question valueForKey:@"id"] valueForKey:@"$oid"])
{
question_id = [[question valueForKey:@"id"] valueForKey:@"$oid"];
}
else
{
question_id = [question valueForKey:@"id"];
}
However, it still doesn't work as the code fails during the checking phase.
How can I implement a check so that I will take question_id from '$oid' only if it exists?