我无法从asihttprequest实现Reachability类。
我跟着this example,但我的选择器从未实现过。这是我的代码
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ReachabilityChanged:) name:kReachabilityChangedNotification object:nil];
Reachability *reach = [Reachability reachabilityForInternetConnection];
[reach startNotifier];
-(void)ReachabilityChanged:(Reachability *)reach{
if ([reach isReachable]) {
NSLog(@"reachable");
}else{
NSLog(@"not reachable");
}
}
我也试过Reachability *reach = [Reachability reachabilityWithHostName:@"http://google.com"];
答案 0 :(得分:1)
您似乎没有保留Reachability
对象,因此reachabilityForInternetConnection
返回的自动释放实例可能会在有机会通知您任何内容之前销毁。