dchohfi / KeyValueObjectMapping

Automatic KeyValue Object Mapping for Objective-C, parse JSON/plist/Dictionary automatically
http://dchohfi.com/
MIT License
601 stars 90 forks source link

fix crash caused by setting nil to a primitive attribute. #81

Open khaledannajar opened 8 years ago

khaledannajar commented 8 years ago

When a wrong value "null" is set to a primitive attribute in the JSON and the DCAttributeSetter try to assign it to the attribute a crash is thrown

Here in this sample JSON book_id in int type and is set to null here I get the crash saying something like that " setNilValueForKey]: could not set nil as the value for the key _book_id.' ":

I fixed it by simply setting @0 to this special case.

{ "name": "andro", "avatar": "http://url/userimage.jpg", "summary": "pla pla pla ", "book_id": null, "datetime": 1455714077 }