YTKNetwork
YTKNetwork copied to clipboard
我按照文档来设置了cacheTimeInSeconds时长,但是并未生效
提出问题前请先确认完成了下列几项步骤 New Issue Checklist
- [x] 我已经阅读过 贡献指南 I have read and understood the CONTRIBUTING guide
- [x] 我已经阅读过 程序文档 I have read the Documentation
- [ ] 我已经证实这个问题来源于 YTKNetwork 本身,而不是其所依赖的 AFNetworking I have confirmed that this issue is caused by YTKNetwork, not AFNetworking
- [x] 我已经在项目的 问题列表 中搜索过并且没有找到类似问题 I have searched for a similar issue in the project and found none
问题描述 Issue Description
请给出所提出问题的详尽描述,包括具体的错误信息,打印的堆栈等等,以及重现此问题的具体步骤。
Please fill in the detailed description of the issue (full output of any stack trace, compiler error, ...) and the steps to reproduce the issue.
#import "IMHomeStockAliveApi.h"
@implementation IMHomeStockAliveApi{
NSString * _action;
NSInteger _page;
NSInteger _pageSize;
}
- (instancetype)initWithAction:(NSString *)action page:(NSInteger)page pageSize:(NSInteger)pageSize{
self = [super init];
if(self){
_action = action;
_page = page;
_pageSize = pageSize;
}
return self;
}
- (id)requestArgument{
return @{@"header":@{kActionString:_action,
kCodeString:@"0",
kDevicetype:IOS,
kMsgTypeString:@"0",
kSendingtimeString:GetCurrentTime,
kVersionString: GetVersionValue, kPageString:@{@"index":[NSString stringWithFormat:@"%zi", _page], @"size":@(_pageSize)}}};
}
- (NSString *)requestUrl{
return DoQuote;
}
- (NSInteger)cacheTimeInSeconds{
return 3600;
}
@end
//直播数据请求
dispatch_async(globleQueue, ^{
IMHomeStockAliveApi * stockAliveApi = [[IMHomeStockAliveApi alloc]initWithAction:@"Q013" page:1 pageSize:3];/**<- 直播*/
if([stockAliveApi loadCacheWithError:nil]){
NSLog(@"cache data");
}
[stockAliveApi startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
NSLog(@"request data");
NSInteger code = [request.responseObject[@"header"][@"code"] integerValue];
if(code == 0){
aliveArray = [IMHomeStockAliveModel modelArrayWithDictArray:request.responseObject[@"datas"]];
}else{
[SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@\n%@", request.responseObject[@"header"][@"code"], request.responseObject[@"header"][@"msg"]]];
}
//请求完毕,发送信号
dispatch_semaphore_signal(semaphtwo);
} failure:^(__kindof YTKBaseRequest * _Nonnull request) {
//请求完毕,发送信号
dispatch_semaphore_signal(semaphtwo);
[SVProgressHUD showErrorWithStatus:NotWork];
}];
});
但是我使用的时候并不会打印cache data 而是直接打印request data ,很迷惑!求教
我也是,一直拿不到这个缓存
同样的问题
+1
同样遇到该问题
一开始我也有这样的问题,后来我发现自定义的请求基类,继承错了YTKBaseRequest 应该继承YTKRequest,哈哈,尴尬