我是 java & php 程序员,遇到了坑爹的iPhone,被逼无奈在崩溃的边缘下学习object-c ,在学习中遇到了不少 奇葩,无知,龌蹉,呕吐的问题(弱弱的说 : 有的些问题到如今还不知道具体的原理)故此把开发中全部遇到的问题,和须要使用的开源库 一一记载下来,为那些苦B的要学习OBJECT-C的屌丝们加点料吧。本文纯粹记录性游记类文章,学术性观摩团请绕行,专家请绕行。在编写过程当中避免不了出现问题或者遗漏问题,但愿你们多多指点与板砖! php
https://github.com/pokeb/asi-http-request html
引入头文件 #import "ASIHTTPRequest.h" java
更详细的使用方法请参照:http://www.cnblogs.com/zhwl/archive/2012/07/14/2591752.html git
- (void)viewDidLoad { [super viewDidLoad]; //请求的后台活动列表 NSURL *url = [NSURL URLWithString:@"http://m.weather.com.cn/data/101180701.html"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request startAsynchronous]; } //异步请求开始 - (void)requestStarted:(ASIHTTPRequest *)request { NSLog(@"request start :%@", @"start"); } //异步请求结束 - (void)requestFinished:(ASIHTTPRequest *)request { // Use when fetching text data NSString *jsonString = [request responseString]; NSLog (@"Response JSON :%@", jsonString); } //异步请求错误 - (void)requestFailed:(ASIHTTPRequest *)request { // NSError *error = [request error]; NSLog (@"Response JSON :%@", @"error"); }
https://github.com/stig/json-framework 程序员
解压后把相应的文件导入到工程中,还没有发现问题 github
在1-3的小试牛刀中,咱们请求了有关天气的URL,这个URL会有一个JSON的相应,咱们继续1-3,来解解析这个响应的JSON json
- (void)viewDidLoad { [super viewDidLoad]; //请求的后台活动列表 //NSURL *url = [NSURL URLWithString:@"http://192.168.1.4/beer/?cat=2&json=1"]; NSURL *url = [NSURL URLWithString:@"http://m.weather.com.cn/data/101180701.html"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request startAsynchronous]; } //异步请求开始 - (void)requestStarted:(ASIHTTPRequest *)request { NSLog(@"request start :%@", @"start"); } //异步请求结束 - (void)requestFinished:(ASIHTTPRequest *)request { NSString *jsonString = [request responseString]; NSLog (@"Response JSON :%@", jsonString); SBJsonParser *parser =[[SBJsonParser alloc] init]; NSDictionary *rootDic = [parser objectWithString:jsonString]; NSDictionary *weatherInfo = [rootDic objectForKey:@"weatherinfo"]; NSLog (@"Response JSON city :%@", [weatherInfo objectForKey:@"city"]); } //异步请求错误 - (void)requestFailed:(ASIHTTPRequest *)request { // NSError *error = [request error]; NSLog (@"Response JSON :%@", @"error"); }
https://github.com/jdg/MBProgressHUD 网络
下载后导入MBProgressHUD.h MBProgressHUD.m 暂时没有发现恶心的问题 异步
导入头文件 MBProgressHUD.h,继续2-3小试牛刀 ,2-3中咱们异步读取天气信息,因此咱们须要在请求前显示加载动画,在请求结束,或网络出现问题时 咱们须要关闭动画 ide
- (void)viewDidLoad { [super viewDidLoad]; //请求的后台活动列表 NSURL *url = [NSURL URLWithString:@"http://m.weather.com.cn/data/101180701.html"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request startAsynchronous]; } //异步请求开始 - (void)requestStarted:(ASIHTTPRequest *)request { NSLog(@"request start :%@", @"start"); [MBProgressHUD showHUDAddedTo:self.view animated:YES]; } //异步请求结束 - (void)requestFinished:(ASIHTTPRequest *)request { [MBProgressHUD hideHUDForView:self.view animated:YES]; NSString *jsonString = [request responseString]; NSLog (@"Response JSON :%@", jsonString); SBJsonParser *parser =[[SBJsonParser alloc] init]; NSDictionary *rootDic = [parser objectWithString:jsonString]; NSDictionary *weatherInfo = [rootDic objectForKey:@"weatherinfo"]; NSLog (@"Response JSON city :%@", [weatherInfo objectForKey:@"city"]); } //异步请求错误 - (void)requestFailed:(ASIHTTPRequest *)request { // NSError *error = [request error]; NSLog (@"Response JSON :%@", @"error"); [MBProgressHUD hideHUDForView:self.view animated:YES]; }
https://github.com/enormego/EGOImageLoading
https://github.com/enormego/EGOTableViewPullRefresh
【5-2 注意事项】
须要在Link Binary with Libraries中加QuartzCore.framework Foundation.framework CoreGraphics.framework 以及 [1-2 中的注意事项]
ECSlidingViewController-master :https://github.com/edgecase/ECSlidingViewController