WTRequestCenter 是一个网络请求类库库,所有的请求都是缓存的。
[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];