有点问题,我的数据加载是在
-
(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,之后再打开网络还是没有加载呢?