汇总iOS开发中需要用到的开源库

移动开发 iOS
我是 java & php 程序员,遇到了坑爹的iPhone,被逼无奈在崩溃的边缘下学习Object-C ,在学习中遇到了很多 奇葩,无知,龌蹉,呕吐的问题(弱弱的说 : 有的些问题到现在还不知道具体的原理)故此把开发中所有遇到的问题,和需要使用的开源库 一一记载下来,为那些苦B的要学习Object-C的屌丝们加点料吧。本文纯粹记录性游记类文章,学术性观摩团请绕行,专家请绕行。在编写过程中避免不了 出现问题或者遗漏问题,希望大家多多指点与板砖!

我是 java & php 程序员,遇到了坑爹的iPhone,被逼无奈在崩溃的边缘下学习Object-C ,在学习中遇到了很多 奇葩,无知,龌蹉,呕吐的问题(弱弱的说 : 有的些问题到现在还不知道具体的原理)故此把开发中所有遇到的问题,和需要使用的开源库 一一记载下来,为那些苦B的要学习Object-C的屌丝们加点料吧。本文纯粹记录性游记类文章,学术性观摩团请绕行,专家请绕行。在编写过程中避免不了 出现问题或者遗漏问题,希望大家多多指点与板砖!

1、iOS &iPhone 网络异步加载 asi-http-request

【1-1 ASI HTTP 下载地址】

    https://github.com/pokeb/asi-http-request

【1-2 注意事项】

下载asi-http-request-master后解压,把\Classes文件下所有文件,\External\Reachabipty 文件夹下所有文件添加到你的工程中。

在 Build Phases中添加相应的pnk Binary With pbraries

(1)MobileCoreServices.framework

(2)SystemConfiguration.framework

(3)CFNetwork.framework

(4)pbz.dypb

由于ARC Restrictions导致的祖国山河一片红

选中相关文件 回车后输入命令:-fno-objc-arc

【1-3 小试牛刀】

引入头文件 #import "ASIHTTPRequest.h"

更详细的使用方法请参照:http://www.cnblogs.com/zhwl/archive/2012/07/14/2591752.html

    - (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"); 

        } 

2、解析JSON数据 SBJSON

【 2-1 SBJSON 下载地址】

https://github.com/stig/json-framework

【2-2 注意事项】

解压后把相应的文件导入到工程中,尚未发现问题

【2-3 小试牛刀】

在1-3的小试牛刀中,我们请求了有关天气的URL,这个URL会有一个JSON的相应,我们继续1-3,来解解析这个响应的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"); 

        } 

3、加载网络数据的时候 显示onLoading动画图片 MBProgressHUD

【3-1 MBProgressHUD 下载地址】

https://github.com/jdg/MBProgressHUD

【3-2 注意事项】

下载后导入MBProgressHUD.h MBProgressHUD.m 暂时没有发现恶心的问题

【3-3 小试牛刀】

导入头文件 MBProgressHUD.h,继续2-3小试牛刀 ,2-3中我们异步读取天气信息,所以我们需要在请求前显示加载动画,在请求结束,或网络出现问题时 我们需要关闭动画

    - (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]; 

        } 

4、iOS &IPhone 异步图片加载 EGOImageLoadding

【EGOImageLoadding 下载地址】

  https://github.com/enormego/EGOImageLoading

 【小试牛刀】

5、上拉刷新,下拉翻页

【5-1 EGOTableViewPullRefresh 下载地址】

https://github.com/enormego/EGOTableViewPullRefresh

【5-2 注意事项】

需要在pnk Binary with pbraries中加QuartzCore.framework Foundation.framework CoreGraphics.framework 以及 [1-2 中的注意事项]

6、左边菜单导航 ECSpdingViewController-master :

https://github.com/edgecase/ECSpdingViewController

责任编辑:闫佳明 来源: oschina
相关推荐

2012-11-21 17:19:55

2021-04-16 23:32:17

区块链工具优秀

2022-07-07 11:58:23

元宇宙区块链虚拟世界

2016-08-25 21:41:29

MarkdownHtmlWeb

2010-04-01 18:08:48

Oracle导入

2023-05-03 09:04:57

2021-10-15 14:48:28

鸿蒙HarmonyOS应用

2014-03-20 09:57:11

2010-04-15 09:34:05

2010-05-12 10:17:59

MySQL数据库优化

2019-08-19 10:15:51

程序员模板版本

2014-11-27 15:38:57

互联网隐私数据

2014-05-13 10:12:17

iOS开发开源类库

2018-03-02 09:30:20

区块链开发语言

2010-06-17 16:30:23

SQL Server数

2010-04-30 13:44:36

Oracle Redo

2018-12-04 10:35:16

2013-02-25 14:13:20

2014-07-30 14:37:00

FacebookiOS开源库

2010-06-11 17:36:46

MySQL语句
点赞
收藏

51CTO技术栈公众号