NSInvalidArgumentException, reason: 'Invalid type in JSON write (__NSDate)'

前端 未结 8 2333
南旧
南旧 2021-02-04 01:05

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?



        
8条回答
  •  轮回少年
    2021-02-04 01:29

    FIrst store your data in NSString. And then convert your string to NSDate.

    You can refer SO:

    Converting NSString to NSDate (and back again)

    NSString to NSDate conversion problem

    How to convert NSString to NSDate using NSDateFormatter?

提交回复
热议问题