CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2018 |
Maintained by chengxianghe.
GitHub:chengxianghe
参照Demo
GET和POST请求仅是配置上有所区别,写法上一致。
普通GET请求
TestRequest *request = [[TestRequest alloc] init];
[request sendRequestWithSuccess:^(__kindof TUBaseRequest * _Nonnull baseRequest, id _Nullable responseObject) {
NSLog(@"requestSuccess:%@", responseObject);
} failur:^(__kindof TUBaseRequest * _Nonnull baseRequest, NSError * _Nonnull error) {
NSLog(@"requestFailur:%@", error);
}];
普通GET请求带缓存读取
TestRequest *request = [[TestRequest alloc] init];
[request sendRequestWithCache:^(__kindof TUBaseRequest * _Nonnull baseRequest, id _Nullable cacheResult, NSError * _Nonnull error) {
if (error) {
NSLog(@"Read Cache Error:%@!", error.description);
} else {
NSLog(@"Read Cache Succeed For Request:%@", NSStringFromClass([request class]));
}
} success:^(__kindof TUBaseRequest * _Nonnull baseRequest, id _Nullable responseObject) {
NSLog(@"requestSuccess:%@", responseObject);
} failur:^(__kindof TUBaseRequest * _Nonnull baseRequest, NSError * _Nonnull error) {
NSLog(@"requestFailur:%@", error);
}];
缓存大小计算
[TUCacheManager getCacheSizeOfAllWithCompletion:^(CGFloat totalSize) {
NSLog(@"%@", [NSString stringWithFormat:@"request缓存大小:%.2f K", totalSize/1024]);
}];
缓存清理
[TUCacheManager getCacheSizeOfAllWithCompletion:^(CGFloat totalSize) {
NSLog(@"开始清理缓存!总缓存大小:%.2f M", totalSize/1024/1024);
[TUCacheManager clearAllCacheWithCompletion:^{
NSLog(@"清理缓存完成!");
sender.enabled = YES;
}];
}];