IOS之路——暮色苍茫(Json)
来源:互联网 发布:手机淘宝如何让人代付 编辑:程序博客网 时间:2024/06/05 05:41
JSONKit
NSError* error;
NSURLRequest* request=[NSURLRequest requestWithRequest:[NSURL URLWithString:@"http://m.weather.com.cn/data/101010100.html"]];NSData* res=[NSURLConnection sendSynchromousRequest:request returningResponse:nil error: nil];NSDictionary *wertherDic=[res objectFromJSONData];NSDictionary *wertherInfo=[wertherDic objectForKey:@"weatherinfo"];txtView.text=[NSString stringWithFormat:@"今天是 %@ %@ %@ 的天气状况是:%@ %@ ",[weatherInfo objectForKey:@"date_y"],[weatherInfo objectForKey:@"week"],[weatherInfo objectForKey:@"city"], [weatherInfo objectForKey:@"weather1"], [weatherInfo objectForKey:@"temp1"]];
ios5
NSError *error; //加载一个NSURL对象 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.weather.com.cn/data/101180601.html"]]; //将请求的url数据放到NSData对象中 NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; //IOS5自带解析类NSJSONSerialization从response中解析出数据放到字典中 NSDictionary *weatherDic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error]; NSDictionary *weatherInfo = [weatherDic objectForKey:@"weatherinfo"]; txtView.text = [NSString stringWithFormat:@"今天是 %@ %@ %@ 的天气状况是:%@ %@ ",[weatherInfo objectForKey:@"date_y"],[weatherInfo objectForKey:@"week"],[weatherInfo objectForKey:@"city"], [weatherInfo objectForKey:@"weather1"], [weatherInfo objectForKey:@"temp1"]];
@property (retain, nonatomic) IBOutlet UITextView *txtView;
@synthesize txtView;
额,我看一般都是有前言的,我也来点。
现在呢,我待业,然后呢,找工作,ios的,要求我去上机(这星期三),说是Json的解析,上网看到个很好的共勉之。
点击打开链接
点击打开链接
- IOS之路——暮色苍茫(Json)
- IOS学习之——JSON解析
- iOS——JSON
- IOS开发之——使用SBJson拼接Json字符串
- IOS成长之路-JSON解析
- IOS成长之路-JSON解析
- IOS成长之路-JSON解析
- iOS——JSON解析
- 《iOS开发笔记—JSON》
- iOS json解析之SBJson
- IOS数据解析之json
- iOS解析之Json解析
- IOS之json转model
- iOS之JSONKit解析JSON
- iOS数据解析之json
- iOS开发基本技能之JSON
- iOS之 json数据解析
- iOS开发实践之JSON
- 制作程序文档_主函数_静态代码块_对象的初始化过程_对象调用成员过程
- xocode不能运行到真机和模拟器上 的 解决方案
- 黑马程序员——Java中的异常:关键字try...catch、throw、throws总结
- 生成n以内的m个随机数
- 调用pthread_mutex_destroy之后是否需要free
- IOS之路——暮色苍茫(Json)
- 在PHP中利用wsdl创建标准webservice的实现代码
- 一道IGT的关于RGB的笔试题
- Ubuntu下deb包的安装方法
- Linux下软件安装方法汇总
- 黑马程序员_java基础(2) 流程控制语句&函数与数组
- 使用xrandr命令设置Ubuntu系统分辨率
- Hello World.
- 解决Firefox is already running问题