AnyObject to Array?

后端 未结 5 1983
既然无缘
既然无缘 2021-01-01 09:49

I\'m using NSJSONSerialization as so:

let twData: AnyObject? = NSJSONSerialization.JSONObjectWithData(responseData, options: NSJSONReadingOption         


        
5条回答
  •  囚心锁ツ
    2021-01-01 10:15

    let twData: Any = NSJSONSerialization.JSONObjectWithData(responseData, options: NSJSONReadingOptions.MutableLeaves, error: &dataError)
    

    Do not use AnyObject. Use Any instead of AnyObject. It will work fine. AnyObject is for all reference type and Array is a value type. That's why this comes. Change it to Any.

提交回复
热议问题