博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jSON Call can throw but it is not marked with try
阅读量:6859 次
发布时间:2019-06-26

本文共 531 字,大约阅读时间需要 1 分钟。

let jsonData:NSDictionary = NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers ) as! NSDictionary

 

第一种用法:

do {   let jsonData = try NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers ) as! NSDictionary   // use jsonData} catch {    // report error} 第二种用法: let jsonData = try NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers ) as! NSDictionary

转载于:https://www.cnblogs.com/luoxiaoxi/p/5046484.html

你可能感兴趣的文章