markdb314 markdb314 - 9 months ago 44
iOS Question

How to pass no options to NSJSONSerialization.JSONObjectWithData in Swift

I want to pass no options when deserializing JSON in Swift (2.0). I originally tried:

NSJSONSerialization.JSONObjectWithData(data, options: nil)

But that doesn't compile, I get the error:

Type NSJSONReadingOptions does not conform to protocol NilLiteralConvertible

The enum NSJSONReadingOptions doesn't have any 'None' option, so what do I do if I don't want of any of these options?


In swift 2 you should use the empty array [] to indicate no options:

NSJSONSerialization.JSONObjectWithData(data, options: [])