Use NSSerialization.datawithJSON in Swift 2

后端 未结 2 1123
无人共我
无人共我 2021-01-05 17:25

Been trying to get this to work in Swift 2.0, the error says:

Type NSJSONWritingOptions cannot conform to protocol NilLiteralConvertible

2条回答
  •  孤街浪徒
    2021-01-05 17:52

    You can also pass an empty array for no options:

    let options:NSJSONWritingOptions = prettyPrinted ? .PrettyPrinted : []
    

提交回复
热议问题