在 Swift (2.0) 中反序列化 JSON 时,我不想传递任何选项。我最初尝试过:
NSJSONSerialization.JSONObjectWithData(data, options: nil)
但这并没有编译,我得到了错误:
Type NSJSONReadingOptions does not conform to protocol NilLiteralConvertible
枚举 NSJSONReadingOptions没有任何“无”选项,如果我不想要这些选项中的任何一个,我该怎么办?
最佳答案
在 swift 2 中,你应该使用空数组 []
来指示 no options
:
NSJSONSerialization.JSONObjectWithData(data, options: [])
关于ios - 如何在 Swift 中不向 NSJSONSerialization.JSONObjectWithData 传递任何选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31708828/