0
在我的項目中,我使用Reachability API。我遵循
Reachability API Documentation給出的代碼示例。kNetworkReachabilityChanged通知API的通知
在我的應用程序委託我已經實現的applicationDidFinishLaunching方法如下,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Observe the kNetworkReachabilityChangedNotification. When that notification is posted, the
// method "reachabilityChanged" will be called.
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];
hostReach = [[Reachability reachabilityWithHostName: NSLocalizedString(@"SERVICE_HOST_URL", nil)] retain];
[hostReach startNotifier];
[self updateReachabilityStatus:hostReach];
self.rootViewController = [[SearchRootViewController alloc] initWithNibName:@"SearchRootView" bundle:nil];
self.detailViewController = [[SearchDetailViewController alloc] initWithNibName:@"SearchView" bundle:nil];
UINavigationController *rootViewNavigationController = [[UINavigationController alloc] initWithRootViewController:self.rootViewController];
UINavigationController *detailViewnavigationController = [[UINavigationController alloc] initWithRootViewController:self.detailViewController];
self.splitViewController = [[UISplitViewController alloc] init];
self.splitViewController.viewControllers = [NSArray arrayWithObjects:rootViewNavigationController, detailViewnavigationController, nil];
[rootViewNavigationController release];
[detailViewnavigationController release];
self.splitViewController.delegate = self.detailViewController;
[self.detailViewController setLeftViewController:self.rootViewController];
[self.window addSubview:[self.splitViewController view]];
[self.window makeKeyAndVisible];
return YES;
}
當這個kNetworkReachabilityChangedNotification發佈?我注意到它不會發布,直到我的detailViewController的視圖出現。
但我想知道在視圖出現之前的網絡狀態。所以,需要您的幫助來了解是否有可能?如果是的話,那麼怎麼樣?
感謝名單