mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 20:31:13 +08:00
Yield to the run loop for a tenth of a second to allow the network reachability observer to be scheduled. This prevents issues where requests dispatched from an app delegate are denied access to the network.
This commit is contained in:
@@ -133,6 +133,11 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
|
||||
if (NO == SCNetworkReachabilityScheduleWithRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) {
|
||||
NSLog(@"Warning -- Unable to schedule reachability observer in current run loop.");
|
||||
}
|
||||
|
||||
// Fire the run loop to allow the observer to be scheduled. This ensures that requests fired
|
||||
// after the observer is scheduled, but before control is yieled to the run loop are not mistakenly
|
||||
// denied dispatching because no network availbility can be determined.
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user