您好,欢迎来到华佗小知识。
搜索
您的当前位置:首页实时网络监测问题

实时网络监测问题

来源:华佗小知识

有点问题,我的数据加载是在

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions
    方法中,然后代码是这样子,按我的理解你的代码应该是实时监测网络,不管在任何界面,只要由无网络状态切换到有网,数据就应该开始加载了...

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
     {
    [GLobalRealReachability startNotifier];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkChanged:) name:kRealReachabilityChangedNotification object:nil];
    // 所有数据更新
     [[NDNewsData sharedData] updateAd];
      // 应用信息更新
      [[NDNewsData sharedData] updateApp];
      // 栏目数据更新
      [[NDNewsData sharedData] updateSource];
      
         return YES;
       }
    
    • (void)networkChanged:(NSNotification *)notification{
      RealReachability * reachability = (RealReachability *)notification.object;
      ReachabilityStatus status = [reachability currentReachabilityStatus];
      if (status != RealStatusNotReachable)
      {
      // 所有数据更新
      [[NDNewsData sharedData] updateAd];

      [[NDNewsData sharedData] updateApp];

      [[NDNewsData sharedData] updateSource];

    }

    • (void)dealloc{
      [[NSNotificationCenter defaultCenter]removeObserver:self name:kRealReachabilityChangedNotification object:nil];
      }

这样写有什么毛病吗?为什么我无网状态下启动app,之后再打开网络还是没有加载呢?

Copyright © 2019- huatuo0.cn 版权所有 湘ICP备2023017654号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务