[[ExamSubRequest shareInstance] requestGetJsonOperationWithParam:nil action:@"getDataList" showLoadHud:YES cancelEnable:YES normalResponse:^(NSInteger status, id _Nonnull data) {
//成功回调
} exceptionResponse:^(NSError * _Nonnull error) {
//失败回调
}];
ExamSubRequest * request1 = [ExamSubRequest shareInstance];
request1.loadCacheFirst = YES;//允许优先从缓存加载
request1.refreshCache = YES;//允许刷新当前缓存
[request1 requestGetJsonOperationWithParam:nil action:@"getDataList"
showLoadHud:YES cancelEnable:YES
normalResponse:^(NSInteger status, id _Nonnull data) {
} exceptionResponse:^(NSError * _Nonnull error) {
}];
//允许优先从缓存加载
-(BOOL)loadCacheFirst
{
return YES;
}
//允许刷新当前缓存
- (BOOL)refreshCache{
return YES;
}
下面方法允许直接网络请求数据解析成对应model返回数据给逻辑层
-(void)requestGetJsonModelWithParam:(NSDictionary *)param
action:(NSString *)action
showLoadHud:(BOOL)showHud
cancelEnable:(BOOL)cancelEnable
modelClass:(Class)modelClass
normalResponse:(void(^)(NSInteger status, id data, NSObject *model))normalResponse
exceptionResponse:(void(^)(NSError *error))exceptionResponse;
-(void)requestGetJsonArrayWithParam:(NSDictionary *)param
action:(NSString *)action
showLoadHud:(BOOL)showHud
cancelEnable:(BOOL)cancelEnable
modelClass:(Class)modelClass
normalResponse:(void(^)(NSInteger status, id data, NSMutableArray *array))normalResponse
exceptionResponse:(void(^)(NSError *error))exceptionResponse;
--(void)requestPostJsonModelWithParam:(NSDictionary *)param
action:(NSString *)action
showLoadHud:(BOOL)showHud
cancelEnable:(BOOL)cancelEnable
modelClass:(Class)modelClass
normalResponse:(void(^)(NSInteger status, id data, NSObject *model))normalResponse
exceptionResponse:(void(^)(NSError *error))exceptionResponse;
-(void)requestPostJsonArrayWithParam:(NSDictionary *)param
action:(NSString *)action
showLoadHud:(BOOL)showHud
cancelEnable:(BOOL)cancelEnable
modelClass:(Class)modelClass
normalResponse:(void(^)(NSInteger status, id data, NSMutableArray *array))normalResponse
exceptionResponse:(void(^)(NSError *error))exceptionResponse;