File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,18 +66,28 @@ - (void)requestJsonDataWithPath:(NSString *)aPath
6666 // 发起请求
6767 switch (method) {
6868 case Get:{
69+ // 所有 Get 请求,增加缓存机制
70+ NSMutableString *localPath = [aPath mutableCopy ];
71+ if (params) {
72+ [localPath appendString: params.description];
73+ }
6974 [self GET: aPath parameters: params success: ^(AFHTTPRequestOperation *operation, id responseObject) {
7075 DebugLog (@" \n ===========response===========\n %@ :\n %@ " , aPath, responseObject);
7176 id error = [self handleResponse: responseObject autoShowError: autoShowError];
7277 if (error) {
73- block (nil , error);
78+ responseObject = [NSObject loadResponseWithPath: localPath];
79+ block (responseObject, error);
7480 }else {
81+ if ([responseObject isKindOfClass: [NSDictionary class ]]) {
82+ [NSObject saveResponseData: responseObject toPath: localPath];
83+ }
7584 block (responseObject, nil );
7685 }
7786 } failure: ^(AFHTTPRequestOperation *operation, NSError *error) {
7887 DebugLog (@" \n ===========response===========\n %@ :\n %@ " , aPath, error);
7988 !autoShowError || [self showError: error];
80- block (nil , error);
89+ id responseObject = [NSObject loadResponseWithPath: localPath];
90+ block (responseObject, error);
8191 }];
8292 break ;}
8393 case Post:{
You can’t perform that action at this time.
0 commit comments