I have Reachability working exactly as suggested in this thread.
I use open source accessibility . However, I do not use blocks, but notifications, so this process is very similar to Apple Reachability code.
The first time I launch the application, I launch it and it works great.
Reachability *reachability = [reach hostReachability];
[reachability startNotifier];
Availability: changed event:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachability_Changed:) name:kReachabilityChangedNotification object:nil];
However, as soon as I press the home button and return to the application, it startNotifierreturns NO instead of YES.
if(!SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue))
{
#ifdef DEBUG
NSLog(@"SCNetworkReachabilitySetDispatchQueue() failed: %s", SCErrorString(SCError()));
#endif
...
return NO;
and therefore, the above event never fires again.
If I use it incorrectly, but startNotifiershould I call it only once in init, when the possibility of achievement is achieved and never again?
self.hostReachability = [Reachability reachabilityWithHostname:_HOST];