IOS开发常用的开源类库3
2014-03-28 16:55
309 查看
10款IOS高效开发必备的Objective-C类库(http://mobile.csdn.net/a/20110317/294018.html)。
1、MBProgressHUD:https://github.com/jdg/MBProgressHUD。
HUD = [[MBProgressHUD alloc]initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate =self;
HUD.labelText =@"Loading";
HUD.detailsLabelText =@"updating data";
[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
以上是一个最简单的实现方法,MBProgressHUD对象可以设置委托,委托方法为hudWasHidden,可以在此方法中remove掉之前创建的变量HUD。
HUD.mode =MBProgressHUDModeDeterminate;设置MBProgressHUD的模式,MBProgressHUD有三种模式,分别为:
MBProgressHUDModeIndeterminate,(UIActivityIndicatorView,default)
MBProgressHUDModeDeterminate,(MBRoundProgressView)
MBProgressHUDModeCustomView
在MBProgressHUDModeDeterminate模式下,可以设置HUD.progress来控制进度。
在MBProgressHUDModeCustomView模式下,可以设置HUD.customView来显示图片,图片大小为37*37时显示效果最好。
MBProgressHUD对象可以自由的在这三种模式之间变换,这样就可以在不同的阶段有不同的呈现形式。
当然还有很多的属性可以设置,以达到不同的目的,具体参见源代码。简单用法参见:/article/4437765.html或者/article/2936108.html。
2、ASIHttpRequest:http://allseeing-i.com/ASIHTTPRequest/或者https://github.com/pokeb/asi-http-request/tree
最简单的连接方式:
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"]];//此处貌似必须加http
[self setRequest:[ASIHTTPRequest requestWithURL:url]];
[request addRequestHeader:@"User-Agent"value:@"ASIHTTPRequest"];
[request startSynchronous];
//其中request为ASIHTTPRequest对象
ASIHTTPRequest中几个比较有用的参数:
url:request请求中的url
requestMethod:提交的方式,默认为GET
postBody:以POST方式提交时所带的数据
responseHeaders:返回的response的Headers
error:错误,可参见ASINetworkErrorType(在ASIHTTPRequest类中)
responseString:这是一个方法,获得返回的结果
。。。。。。。。
request可以设置代理:[request setDelegate:***];
还可以设置进度条:[request setDownloadProgressDelegate:***];
使用ASINetworkQueue可以实现多线程的方式进行数据的获取。使用方法与NSOperationQueue类似.
使用ASIFormDataRequest进行POST方式提交,使用setPostValue增加post的值,当然你也可以用addPostValue。
3、JSON Framework:参见我的文章(http://blog.csdn.net/xiaoguan2008/article/details/6732683)
4、Flurry:一个很强大的统计工具,http://www.flurry.com/product/analytics/index.html
使用起来也很简单,首先在Flurry网站上进行注册(https://dev.flurry.com/secure/login.do),成功后new
application,此时会有相应的sdk给你下载。下载后直接加入到你的工程中即可。接下来是使用:
In your Application Delegate:
Import FlurryAnalytics and inside "applicationDidFinishLaunching:" add: [FlurryAnalytics startSession:@"PTVUJQUHI6MUMJP22GQK"];
#import "FlurryAnalytics.h"
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[FlurryAnalytics startSession:@"PTVUJQUHI6MUMJP22GQK"];//每个应用程序的唯一标示,flurry生成的。
//your code
}
You can use the following methods to report additional data.
Tracking User Behavior
[FlurryAnalytics logEvent:@"EVENT_NAME"];
[FlurryAnalytics logEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary];
An example NSDictionary to use with this method could be: NSDictionary *dictionary =
[NSDictionary dictionaryWithObjectsAndKeys:@"your dynamic parameter value",
@"your dynamic parameter name",
nil];
[FlurryAnalytics logEvent:@"EVENT_NAME" timed:YES];
[FlurryAnalytics logEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary timed:YES];
[FlurryAnalytics endTimedEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary];
[FlurryAnalytics logAllPageViews:navigationController];
[FlurryAnalytics logPageView];
Tracking Application Errors
[FlurryAnalytics logError:@"ERROR_NAME" message:@"ERROR_MESSAGE" exception:e];
Use this to log exceptions and/or errors that occur in your app. Flurry will report the first 10 errors that occur in each session.
我们还可以使用flurry记录程序意外的crash信息,如下:
We recommend adding an uncaught exception listener to your application (if you don't already have one) and use logError to record any application
crashes. Adding an uncaught exception listener is easy; you just need to create a function that looks like the following:
void uncaughtExceptionHandler(NSException *exception) {
[FlurryAnalytics logError:@"Uncaught" message:@"Crash!" exception:exception];
}
You then need to register this function as an uncaught exception listener as follows:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
[FlurryAnalytics startSession:@"PTVUJQUHI6MUMJP22GQK"];
....
}
Note that you can name the function whatever you'd like and record whatever error information you'd like in the error name and event fields.
1、MBProgressHUD:https://github.com/jdg/MBProgressHUD。
HUD = [[MBProgressHUD alloc]initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate =self;
HUD.labelText =@"Loading";
HUD.detailsLabelText =@"updating data";
[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
以上是一个最简单的实现方法,MBProgressHUD对象可以设置委托,委托方法为hudWasHidden,可以在此方法中remove掉之前创建的变量HUD。
HUD.mode =MBProgressHUDModeDeterminate;设置MBProgressHUD的模式,MBProgressHUD有三种模式,分别为:
MBProgressHUDModeIndeterminate,(UIActivityIndicatorView,default)
MBProgressHUDModeDeterminate,(MBRoundProgressView)
MBProgressHUDModeCustomView
在MBProgressHUDModeDeterminate模式下,可以设置HUD.progress来控制进度。
在MBProgressHUDModeCustomView模式下,可以设置HUD.customView来显示图片,图片大小为37*37时显示效果最好。
MBProgressHUD对象可以自由的在这三种模式之间变换,这样就可以在不同的阶段有不同的呈现形式。
当然还有很多的属性可以设置,以达到不同的目的,具体参见源代码。简单用法参见:/article/4437765.html或者/article/2936108.html。
2、ASIHttpRequest:http://allseeing-i.com/ASIHTTPRequest/或者https://github.com/pokeb/asi-http-request/tree
最简单的连接方式:
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"]];//此处貌似必须加http
[self setRequest:[ASIHTTPRequest requestWithURL:url]];
[request addRequestHeader:@"User-Agent"value:@"ASIHTTPRequest"];
[request startSynchronous];
//其中request为ASIHTTPRequest对象
ASIHTTPRequest中几个比较有用的参数:
url:request请求中的url
requestMethod:提交的方式,默认为GET
postBody:以POST方式提交时所带的数据
responseHeaders:返回的response的Headers
error:错误,可参见ASINetworkErrorType(在ASIHTTPRequest类中)
responseString:这是一个方法,获得返回的结果
。。。。。。。。
request可以设置代理:[request setDelegate:***];
还可以设置进度条:[request setDownloadProgressDelegate:***];
使用ASINetworkQueue可以实现多线程的方式进行数据的获取。使用方法与NSOperationQueue类似.
使用ASIFormDataRequest进行POST方式提交,使用setPostValue增加post的值,当然你也可以用addPostValue。
3、JSON Framework:参见我的文章(http://blog.csdn.net/xiaoguan2008/article/details/6732683)
4、Flurry:一个很强大的统计工具,http://www.flurry.com/product/analytics/index.html
使用起来也很简单,首先在Flurry网站上进行注册(https://dev.flurry.com/secure/login.do),成功后new
application,此时会有相应的sdk给你下载。下载后直接加入到你的工程中即可。接下来是使用:
In your Application Delegate:
Import FlurryAnalytics and inside "applicationDidFinishLaunching:" add: [FlurryAnalytics startSession:@"PTVUJQUHI6MUMJP22GQK"];
#import "FlurryAnalytics.h"
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[FlurryAnalytics startSession:@"PTVUJQUHI6MUMJP22GQK"];//每个应用程序的唯一标示,flurry生成的。
//your code
}
You can use the following methods to report additional data.
Tracking User Behavior
[FlurryAnalytics logEvent:@"EVENT_NAME"];
[FlurryAnalytics logEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary];
An example NSDictionary to use with this method could be: NSDictionary *dictionary =
[NSDictionary dictionaryWithObjectsAndKeys:@"your dynamic parameter value",
@"your dynamic parameter name",
nil];
[FlurryAnalytics logEvent:@"EVENT_NAME" timed:YES];
[FlurryAnalytics logEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary timed:YES];
[FlurryAnalytics endTimedEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary];
[FlurryAnalytics logAllPageViews:navigationController];
[FlurryAnalytics logPageView];
Tracking Application Errors
[FlurryAnalytics logError:@"ERROR_NAME" message:@"ERROR_MESSAGE" exception:e];
Use this to log exceptions and/or errors that occur in your app. Flurry will report the first 10 errors that occur in each session.
我们还可以使用flurry记录程序意外的crash信息,如下:
We recommend adding an uncaught exception listener to your application (if you don't already have one) and use logError to record any application
crashes. Adding an uncaught exception listener is easy; you just need to create a function that looks like the following:
void uncaughtExceptionHandler(NSException *exception) {
[FlurryAnalytics logError:@"Uncaught" message:@"Crash!" exception:exception];
}
You then need to register this function as an uncaught exception listener as follows:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
[FlurryAnalytics startSession:@"PTVUJQUHI6MUMJP22GQK"];
....
}
Note that you can name the function whatever you'd like and record whatever error information you'd like in the error name and event fields.
相关文章推荐
- IOS开发常用的开源类库和一些示例
- IOS开发常用的开源类库
- iphone开发常用开源库1----常用的几个提高iOS开发效率的开源类库及工具
- IOS开发常用的开源类库和一些示例
- 提高IOS开发效率的常用网站、开源类库及工具
- 记录常用的几个提高iOS开发效率的开源类库及工具
- 常用的几个提高iOS开发效率的开源类库及工具
- 常用的几个提高iOS开发效率的开源类库及工具
- 常用的几个提高iOS开发效率的开源类库及工具
- IOS开发常用的开源类库1
- 我常用的几个提高iOS开发效率的开源类库及工具
- ios开发常用的开源类库和一些示例
- IOS开发常用的开源类库2
- 常用的几个提高iOS开发效率的开源类库及工具
- IOS开发常用的开源类库4
- 我常用的几个提高iOS开发效率的开源类库及工具
- IOS开发常用的开源类库5
- IOS开发常用的开源类库和一些示例(转)
- iphone开发常用开源库1----常用的几个提高iOS开发效率的开源类库及工具
- [ios]【转】IOS开发常用的开源类库及下载地址