我有这个场景,UIViewController => UITableViewController => UITableViewController =>的UIViewController。
从第一个UITableViewController,我检查互联网连接并根据它填充数据。
这就是问题所在 - 1.首先是UITableViewController wi-fi,所以从URL填充数据, 2.关闭wi-fi并选择行并转到第二个UITableViewController,网络状态为NotReachable,数据从数据库中填充 3.我打开wi-fi并选择行并转到最后一个UIViewcontroller,这里网络状态是NotReachable,而它应该是ReachableViaWiFi
我错过了什么吗?请建议。
-(void) viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(reachabilityChanged:)
name: kReachabilityChangedNotification
object: nil];
Reachability *reach = [Reachability reachabilityWithHostname: @"www.apple.com"];
[reach startNotifier];
}
- (void) reachabilityChanged: (NSNotification *)notification {
Reachability *reach = [notification object];
if( [reach isKindOfClass: [Reachability class]]) {
NetworkStatus status = [reach currentReachabilityStatus];
switch(status) {
case NotReachable:
{
if (!performedOnce) {
[self processOffline];
performedOnce = YES;
}
[[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil];
}
break;
default:
{
if (!performedOnce) {
[self retrieveUserListWithUrl];
performedOnce = YES;
}
[[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil];
}
break;
}
}
}