Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting JSON to NSData for Archival

I’m trying to archive one of my classes via NSCoding but one of the properties is JSON. I’m using SwiftyJSON to convert the JSON to NSData with the encodeWithCoder method but I occasionally get a fatal error: “‘NSInvalidArgumentException’, reason: ‘*** +[NSJSONSerialization dataWithJSONObject:options:error:]”.

like image 497
Cognitio Avatar asked Jan 21 '26 05:01

Cognitio


1 Answers

I was having the same issue. Instead of converting the JSON to NSData I converted it to a String and then encoded that instead. That’s been working for me.

like image 138
nil Avatar answered Jan 23 '26 01:01

nil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!