情况是这样的,每次请求总是时好时坏,要么成功,要么就报这个方法里面的错误
-(void) reachabilityChanged:(NSNotification*) notification
{
if([self.reachability currentReachabilityStatus] == ReachableViaWiFi)
{
DLog(@"Server [%@] is reachable via Wifi", self.hostName);
[_sharedNetworkQueue setMaxConcurrentOperationCount:6];
[self checkAndRestoreFrozenOperations];
}
else if([self.reachability currentReachabilityStatus] == ReachableViaWWAN)
{
if(self.wifiOnlyMode) {
DLog(@" Disabling engine as server [%@] is reachable only via cellular data.", self.hostName);
[_sharedNetworkQueue setMaxConcurrentOperationCount:0];
} else {
DLog(@"Server [%@] is reachable only via cellular data", self.hostName);
[_sharedNetworkQueue setMaxConcurrentOperationCount:2];
[self checkAndRestoreFrozenOperations];
}
}
else if([self.reachability currentReachabilityStatus] == NotReachable)
{
DLog(@"Server [%@] is not reachable", self.hostName);
[self freezeOperations];
}
if(self.reachabilityChangedHandler) {
self.reachabilityChangedHandler([self.reachability currentReachabilityStatus]);
}
}
请教 @sycx 老师之前用MKNetworkKit的时候碰到过这种奇怪的问题吗?
我也遇到那个问题,经常崩溃,是MKNetworkEngine这个类,-(void) reachabilityChanged:(NSNotification*) notification 这个方法,[self.reachability currentReachabilityStatus] 这个判断。