Skip to content

Commit

Permalink
Fix Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Arc-lin committed Jun 10, 2017
1 parent e188e85 commit 8625ab3
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ALNetworking.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
7 changes: 7 additions & 0 deletions ALNetworking/ALNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)];

Expand All @@ -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];
}];
Expand Down
6 changes: 6 additions & 0 deletions ALNetworking/ALNetworkingDetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
<tr>
<td>{url}</td>
</tr>
<tr>
<td>请求头</td>
</tr>
<tr>
<td>{header}</td>
</tr>
<tr>
<td>参数</td>
</tr>
Expand Down
3 changes: 3 additions & 0 deletions ALNetworking/ALNetworkingResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
/** 网络异常错误 */
@property (nonatomic, strong) NSError *error;

/** 是否是取缓存的响应 */
@property (nonatomic, assign) BOOL isCache;

@end
2 changes: 1 addition & 1 deletion ALNetworking/ALNetworkingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
13 changes: 4 additions & 9 deletions ALNetworking/UIViewController+ALExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;

Expand All @@ -49,11 +49,6 @@ - (void)logger_viewDidLoad
}
}

- (void)logger_viewWillAppear:(BOOL)animate
{
[self logger_viewWillAppear:animate];
}

- (void)showLoggerViewController
{
if([ALNetworking sharedInstance].config.debugMode) { // 如果是调试模式的话
Expand Down
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 8625ab3

Please sign in to comment.