Call can throw but it is not marked with try

来源:互联网 发布:浦东国税局 知乎 编辑:程序博客网 时间:2024/05/19 03:18

错误原因:

let dic =  NSJSONSerialization.JSONObjectWithData(datas!, options: .MutableContainers)

正确写法:
        do {
                let jsonData = try NSJSONSerialization.JSONObjectWithData(datas!, options: .MutableContainers)
                print(jsonData)
               
            } catch {
               
            }

0 0
原创粉丝点击