- (void)loadDataFromUrl
{
NSURL* url = [NSURL URLWithString:@"http://m.weather.com.cn/data/101190408.html"];
NSMutableURLRequest * urlRequest=[NSMutableURLRequest requestWithURL:url];
NSURLConnection* urlConn = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
[urlConn start];
} - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse*)response
{
NSHTTPURLResponse* rsp = (NSHTTPURLResponse*)response;
int code = [rsp statusCode];
if (code != )
{
[connection cancel];
[connection release];
connection = nil;
}
else
{
if (mData != nil)
{
[mData release];
mData = nil;
}
mData = [[NSMutableData alloc] init];
}
} - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[mData appendData:data];
} - (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// [self hideAlert];
NSString* backString = [[NSMutableString alloc] initWithData:mData encoding:NSUTF8StringEncoding];
NSMutableDictionary *backData =[backString JSONValue];
NSLog(@"%@",backData);
connection = nil;
} -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
[connection release];
connection = nil;
} -(void)showAlertView:(NSString*)titleStr
{
UIAlertView *myalert = [[UIAlertView alloc]
initWithTitle:@"提示"
message:titleStr
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:nil];
[myalert show];
[myalert release];
}

最新文章

  1. svn小设置
  2. Configuring Network in CentOS 6.3 Virtual Box + Screenshots
  3. 基于 ThinkPHP 3.2.3 的页面静态化功能的实现
  4. saltstack之(六)配置管理state
  5. PAT 05-树8 Huffman Codes
  6. Ubuntu下eclipse的Extjs提示插件安装
  7. UMeng 友盟的用户数,启动数 等
  8. nodejs服务端开发学习笔记
  9. 某IT校招笔试
  10. 如何实现自己的ClassLoader
  11. Spring Boot快速建立HelloWorld项目
  12. Version 1.6.0 of the JVM is not suitable for the this product.Version:1.8 or greater is required
  13. HTTP 400 错误 - 请求无效 (Bad request)
  14. byte[] 解析、转码二三事
  15. Python高阶函数map、reduce、filter、sorted的应用
  16. 多线程情况下HashMap死循环的问题
  17. 6 scrapy框架之分布式操作
  18. mysql 批量更新的四种方法
  19. TMG 2010 为HTTPS协议添加非标准端口(443)
  20. 最近面试js部分试题总结

热门文章

  1. javaee后台适合用的编辑器插件
  2. IIS 配置好了,为什么网站打开一片空白?
  3. 注册表修改IP地址和DNS等信息
  4. Content-Disposition的使用和注意事项
  5. loop_login.sh
  6. 你好,C++(40)7.1 一切指针都是纸老虎:彻底理解指针
  7. 九度OJ 1025 最大报销额(01背包)
  8. 零散的笔记:jquery中的事件
  9. STL容器介绍
  10. ch01.深入理解C#委托及原理(转)