WTRequestCenter
- 授权协议: Apache
- 开发语言: Objective-C
- 操作系统: iOS
- 软件首页: https://github.com/swtlovewtt/WTRequestCenter
软件介绍
WTRequestCenter 是一个网络请求类库库,所有的请求都是缓存的。
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 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];
