本文介绍了NSInvalidArgumentException,原因:'JSON写入中的无效类型(__NSDate)'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试JSON编码NSDate对象时,我收到此异常。我相信NSDate与JSON编码不兼容。但我必须编码date.Any解决方案?
I'm getting this exception when I try to JSON encode NSDate object.I believe NSDate is not compatible for JSON encoding. but I must encode the date.Any solutions?
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (__NSDate)'推荐答案
第一个商店NSString中的数据。然后将您的字符串转换为NSDate。
FIrst store your data in NSString. And then convert your string to NSDate.
您可以参考SO:
将NSString转换为NSDate(并再次返回)
NSString转换为NSDate转换问题
如何使用NSDateFormatter将NSString转换为NSDate?
更多推荐
NSInvalidArgumentException,原因:'JSON写入中的无效类型(
发布评论