私は同じことで問題を抱えていましたが、タイムアウトを指定する方法を見つけました。Apple の到達可能性クラス内でこのメソッドを置き換えました。
- (NetworkStatus)currentReachabilityStatus
{
NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef");
//NetworkStatus returnValue = NotReachable;
__block SCNetworkReachabilityFlags flags;
__block BOOL timeOut = NO;
double delayInSeconds = 5.0;
dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(delay, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(void){
timeOut = YES;
});
__block NetworkStatus returnValue = NotReachable;
__block BOOL returned = NO;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags))
{
if (_alwaysReturnLocalWiFiStatus)
{
returnValue = [self localWiFiStatusForFlags:flags];
}
else
{
returnValue = [self networkStatusForFlags:flags];
}
}
returned = YES;
});
while (!returned && !timeOut) {
if (!timeOut && !returned){
[NSThread sleepForTimeInterval:.02];
} else {
break;
}
}
return returnValue;
}