if the google.com don't work! but the net is ok. the code will bring error. so I want to remove the "google.com" to detect the status of net .
I can't find the method of Reachability without address.
#import "Reachability.h"
static ReachabilityCenter *reachCenter;
@implementation ReachabilityCenter
@synthesize reachablity;
@synthesize isConnectedNet;
+(id)shareCenter
{
if(!reachCenter)
{
reachCenter = [[ReachabilityCenter alloc] init];
reachCenter.reachablity = [Reachability reachabilityWithHostname:@"www.google.com"];
}
return reachCenter;
}
-(void)reachabilityChanged:(NSNotification*)note
{
Reachability * reach = [note object];
isConnectedNet = [reach isReachable];
}
-(void)beginListening
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged:)
name:kReachabilityChangedNotification
object:nil];
[reachCenter.reachablity startNotifier];
}
@end
I test the code detect the status without website,ip.
-(void)detectNetStatus
{
Reachability *r = [Reachability reachabilityForLocalWiFi];
isConnectedNet = [r currentReachabilityStatus];
}
-(NetworkStatus)isConnectedNet
{
[self detectNetStatus];
return isConnectedNet;
}