From 8625ab39cc9880bb1804cbd0ffe9994dede40a60 Mon Sep 17 00:00:00 2001 From: Arclin Date: Sat, 10 Jun 2017 23:50:37 +0800 Subject: [PATCH] Fix Bugs --- ALNetworking.podspec | 2 +- ALNetworking/ALNetworking.m | 7 +++++++ ALNetworking/ALNetworkingDetail.html | 6 ++++++ ALNetworking/ALNetworkingResponse.h | 3 +++ ALNetworking/ALNetworkingViewController.m | 2 +- ALNetworking/UIViewController+ALExtension.m | 13 ++++-------- LICENSE.txt | 22 +++++++++++++++++++++ 7 files changed, 44 insertions(+), 11 deletions(-) create mode 100755 LICENSE.txt diff --git a/ALNetworking.podspec b/ALNetworking.podspec index 592bff1..dba2f2e 100644 --- a/ALNetworking.podspec +++ b/ALNetworking.podspec @@ -85,7 +85,7 @@ Pod::Spec.new do |s| # Supports git, hg, bzr, svn and HTTP. # - s.source = { :git => "https://github.com/Arc-lin/ALNetworking.git", :tag => "1.0" } + s.source = { :git => "https://github.com/Arc-lin/ALNetworking.git", :tag => "1.0.1" } # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # diff --git a/ALNetworking/ALNetworking.m b/ALNetworking/ALNetworking.m index cd30746..1948cd3 100644 --- a/ALNetworking/ALNetworking.m +++ b/ALNetworking/ALNetworking.m @@ -221,6 +221,9 @@ - (RACSignal *)cacheWithRequest:(ALNetworkingRequest *)request [subscriber sendError:KERROR(-99, @"NO CACHE")]; } else { + // 确认是取缓存的响应体 + response.isCache = YES; + // 添加进入历史记录中 [self.requestHistories addObject:RACTuplePack([NSDate date],request,response)]; @@ -244,6 +247,10 @@ - (RACSignal *)networkWithRequest:(ALNetworkingRequest *)request cache:(BOOL)cac @strongify(self); if(cache) { [[RACScheduler scheduler] schedule:^{ + + // 确认不是取缓存的响应体 + response.isCache = NO; + // 把请求结果写入缓存 [self.cache setObject:response forRequestUrl:request.urlStr params:request.params]; }]; diff --git a/ALNetworking/ALNetworkingDetail.html b/ALNetworking/ALNetworkingDetail.html index 6a38933..f4ea035 100644 --- a/ALNetworking/ALNetworkingDetail.html +++ b/ALNetworking/ALNetworkingDetail.html @@ -18,6 +18,12 @@ {url} + + 请求头 + + + {header} + 参数 diff --git a/ALNetworking/ALNetworkingResponse.h b/ALNetworking/ALNetworkingResponse.h index c090d43..81535f1 100644 --- a/ALNetworking/ALNetworkingResponse.h +++ b/ALNetworking/ALNetworkingResponse.h @@ -16,4 +16,7 @@ /** 网络异常错误 */ @property (nonatomic, strong) NSError *error; +/** 是否是取缓存的响应 */ +@property (nonatomic, assign) BOOL isCache; + @end diff --git a/ALNetworking/ALNetworkingViewController.m b/ALNetworking/ALNetworkingViewController.m index 211e7f0..a7d5c00 100644 --- a/ALNetworking/ALNetworkingViewController.m +++ b/ALNetworking/ALNetworkingViewController.m @@ -119,7 +119,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath @"{paramsType}":request.paramsTypeStr, @"{stategy}":request.strategyStr, @"{method}":request.methodStr, - @"{isCache}":@"", + @"{isCache}":response.isCache ? @"True" : @"False", @"{response}":respData}; [dic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { htmlStr = [htmlStr stringByReplacingOccurrencesOfString:key withString:obj]; diff --git a/ALNetworking/UIViewController+ALExtension.m b/ALNetworking/UIViewController+ALExtension.m index aefafc4..c2a128e 100644 --- a/ALNetworking/UIViewController+ALExtension.m +++ b/ALNetworking/UIViewController+ALExtension.m @@ -18,8 +18,8 @@ + (void)load static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ Class class = [self class]; - SEL originalSelector1 = @selector(viewDidLoad); - SEL swizzledSelector1 = @selector(logger_viewDidLoad); + SEL originalSelector1 = @selector(viewDidAppear:); + SEL swizzledSelector1 = @selector(logger_viewDidAppear:); Method originalMethod1 = class_getInstanceMethod(class, originalSelector1); Method swizzledMethod1 = class_getInstanceMethod(class, swizzledSelector1); BOOL didAddMethod1 = class_addMethod(class,originalSelector1,method_getImplementation(swizzledMethod1),method_getTypeEncoding(swizzledMethod1)); @@ -31,9 +31,9 @@ + (void)load }); } -- (void)logger_viewDidLoad +- (void)logger_viewDidAppear:(BOOL)animated { - [self logger_viewDidLoad]; + [self logger_viewDidAppear:animated]; UIGestureRecognizer *customGesture = [ALNetworking sharedInstance].config.gesture; @@ -49,11 +49,6 @@ - (void)logger_viewDidLoad } } -- (void)logger_viewWillAppear:(BOOL)animate -{ - [self logger_viewWillAppear:animate]; -} - - (void)showLoggerViewController { if([ALNetworking sharedInstance].config.debugMode) { // 如果是调试模式的话 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100755 index 0000000..355c1f8 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ + + +Copyright (c) 2015 coderyi. +This code is distributed under the terms and conditions of the MIT license. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in the +Software without restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +