NSJSONSerialization bug?

前端 未结 2 1092
死守一世寂寞
死守一世寂寞 2021-01-04 07:02

Been trying to debug a crash for the past 10 hours and finally, I simplified it to this code:

NSError *error = nil;
NSData *data = [NSData dataWithContentsOf         


        
相关标签:
2条回答
  • 2021-01-04 07:38

    It looks like Apple did a bad work in error handling of such cases within their class, since your getting crash instead of normal nil result and error variable populated. Your json data and minimalistic code is what Apple usually require for a proper bug report. Report the bug by following link - https://developer.apple.com/bugreporter/ do not forget to attach project in zip as a proof that it crashes.

    0 讨论(0)
  • 2021-01-04 07:47

    I had this issue and for me, the issue was a duplicate key in the JSON. My key was named differently - not "is_subscribed" like in your case, but "food_nutrients". I'm willing to bet that iOS 6 crashes on any duplicate keys where there's another key in between - not just an "is_subscribed" key as some of the comments suggest.

    I've confirmed that duplicate keys of any name are the issue. Related: https://stackoverflow.com/a/21148319/2030

    0 讨论(0)
提交回复
热议问题