1
votes

Basically, I'm having the same problem as described here, but as I'm using a newer version of RestKit (v0.20.0-rc1 to be exact) I can't use the workaround mentioned in the answer.

I'm trying to map an array of videos, which works fine as long as there is at least one object in the JSON response:

"videos": {"video": [
  {
   "id": 7066,
   "name": "firstVideo",
  },
  {
   "id": 7068,
   "name": "secondVideo",
  }
 ]}

When there are no videos I get this response:

"videos": ""

This causes my app to crash with the following message:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFConstantString 0x17db2d0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key video.'

Any help is appreciated.

1

1 Answers

0
votes

When the "videos" tag is gone there will be an array of objects.Dont worry about the outer array.Create a mapping for "video" and call your service .It will return an array in mapping result which can be obtained as [mappingResult array]