优秀的缓存请求库,快速请求接口和图片:WTRequestCenter

WTRequestCenter

方便缓存的请求库无需任何import和配置,目前实现了基础需求如果有其他需要请在issue 上提出,谢谢!

使用方法 Usage

注意:所有的请求都是缓存的

GET 请求

[WTRequestCenter getWithURL:url
parameters:parameters
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
id obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];
NSLog(@"result:%@",obj);
}

POST 请求

[WTRequestCenter postWithURL:url
parameters:parameters
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
id obj = [NSJSONSerialization http://www.bsck.org/JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];
NSLog(@"result:%@",obj);
}

缓存图片

NSURL *url = [NSURL URLWithString:@"http://www.xxx.com/eqdsa.jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
[WTRequestCenter getImageWithURL:url imageComplectionHandler:^(UIImage *image) {
imageView.image = image;
}];

取消所有请求

[WTRequestCenter cancelAllRequest]; 

Requirement

Only need iOS 5.0 and later,no more!

需要

仅仅需要iOS5 ! 不需要其他任何import和配置

原文地址:https://www.cnblogs.com/tianshifu/p/6361804.html