Skip to content

Commit

Permalink
网络监听修改
Browse files Browse the repository at this point in the history
  • Loading branch information
wujunyang committed Oct 28, 2016
1 parent 929d975 commit ebe7305
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 0 additions & 3 deletions jiaModuleDemo/BaseModule/JiaCore/JiaAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
@implementation JiaAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//网络状态通知监听
[GLobalRealReachability startNotifier];

//是否开始日志记录功能
if(JiaCoreConfigManagerInstance.isRecordlogger)
Expand Down
7 changes: 5 additions & 2 deletions jiaModuleDemo/BaseModule/JiaCore/JiaBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ -(void)viewDidLoad
[self configRightBaritemWithImage];
}

//添加一个通知监听网络状态切换
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(networkChanged:)
name:kRealReachabilityChangedNotification
object:nil];
[GLobalRealReachability startNotifier];

ReachabilityStatus status = [GLobalRealReachability currentReachabilityStatus];
//当无网络时 每进一个页面都进行提示
if (status == RealStatusNotReachable)
Expand Down Expand Up @@ -110,6 +113,7 @@ -(void)viewDidAppear:(BOOL)animated

-(void)dealloc
{
[GLobalRealReachability stopNotifier];
//移除通知
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
Expand Down Expand Up @@ -270,8 +274,7 @@ - (void)networkChanged:(NSNotification *)notification
{
RealReachability *reachability = (RealReachability *)notification.object;
ReachabilityStatus status = [reachability currentReachabilityStatus];
ReachabilityStatus previousStatus = [reachability previousReachabilityStatus];
NSLog(@"networkChanged, currentStatus:%@, previousStatus:%@", @(status), @(previousStatus));


if (status == RealStatusNotReachable)
{
Expand Down

0 comments on commit ebe7305

Please sign in to comment.