NSInvalidArgumentException,原因:'JSON写入中的无效类型(

编程入门 行业动态 更新时间:2024-10-27 23:27:37
本文介绍了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写入中的无效类型(

本文发布于:2023-11-26 04:46:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632683.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:原因   类型   NSInvalidArgumentException   JSON

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!