Har*_*rsh 5 iphone reachability ios4
我使用过Andrew的修改后的Reachability类.
-(void)viewDidLoad
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
下载数据时,我会AirPort关闭.但是checkNetworkStatus没有被召唤.我错过了什么.请帮我.这个问题让我疯了.提前致谢.
rck*_*nes 11
您是否告诉可达性实例开始广播通知?
Reachability *internetReachable = [Reachability reachabilityForInternetConnection];
// This will tell the notifier to start sending notifications
[internetReachable startNotifier];
Run Code Online (Sandbox Code Playgroud)
按照这个顺序
在你看来确实加载了
首先注册
然后
发布该通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:nil];
Run Code Online (Sandbox Code Playgroud)