Swift Json 解析异常处理
来源:互联网 发布:问道手游辅助软件 编辑:程序博客网 时间:2024/05/23 19:19
{
// 1.获取本地json文件路径
let jsonPath =NSBundle.mainBundle().pathForResource("MainVCSettings.json", ofType:nil)
// 2.加载json数据
let jsonData =NSData(contentsOfFile: jsonPath!)
// 3.序列化json
do{
// throw是Xcode7最明显的一个变化, Xcode7之前都是通过传入error指针捕获异常, Xocode7开始通过try/catch捕获异常
let dictArray =try NSJSONSerialization.JSONObjectWithData(jsonData!, options:NSJSONReadingOptions.MutableContainers)
// 遍历字典时候需要明确指明数组中的数据类型
for dictin dictArray as! [[String:String]]
{
// 由于addChildVC方法参数不能为nil, 但是字典中取出来的值可能是nil, 所以需要加上!
addChildViewController(dict["vcName"]!, title: dict["title"]!, imageName: dict["imageName"]!)
}
}catch{
addChildViewController("HomeTableViewController", title:"首页", imageName: "tabbar_home")
addChildViewController("MessageTableViewController", title:"消息", imageName: "tabbar_message_center")
addChildViewController("DiscoverTableViewController", title:"发现", imageName: "tabbar_discover")
addChildViewController("ProfileTableViewController", title:"我", imageName: "tabbar_profile")
}
}
- Swift Json 解析异常处理
- iOS 中json数据解析异常处理
- Gson&FastJson解析异常Json的处理
- swift 解析json数据
- Swift解析JSON数据
- 使用swift解析json
- Swift 解析 JSON
- iOS Json解析Swift
- swift的json解析
- swift 异常处理
- Swift 2.0 异常处理
- Swift 2.0 异常处理
- Swift 异常处理
- Swift-异常处理
- 【JSON】解析JSON格式异常
- json解析异常
- iOS Swift-Json解析
- IOS学习--- Swift JSON解析
- Ueditor解决safari浏览器粘贴图片问题
- PHP微信支付接口开发
- opengl 入门学习路径
- centos7 ceph安装
- java反射机制详解 及 Method.invoke解释
- Swift Json 解析异常处理
- Python装饰器
- linux挂载ISO光盘镜像
- LAST_INSERT_ID(), LAST_INSERT_ID(expr)
- 抓包Fidder
- TabLayout+Fragment
- tomcat配置,通过域名访问指定项目
- shiro整合springmvc
- [转]如何更改AD域安全策略-密码必须符合复杂性要求