2013-03-16 89 views
1

我使用最新的AFNetworking资源,并且可用性对我不起作用,它永远不会触发可用性块,并且[httpClient networkReachabilityStatus]始终返回-1。 SystemConfiguration/SystemConfiguration.h包含在.pch中AFNetworking - 始终返回-1

startMonitoringNetworkReachability被执行(在AFHTTPClient中)。

iPhone 4,iOS 6.1

有什么建议吗?

AFHTTPClient *httpClient   = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:URL]]; 

    [httpClient setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { 

     NSLog(@"Internet status changed"); 
     NSLog(@"%d", status); 
    }]; 


    NSMutableURLRequest *request        = [httpClient requestWithMethod:@"POST" path:method parameters:post]; 

    NSLog(@"Network reach %d",[httpClient networkReachabilityStatus]); 

    AFJSONRequestOperation *operation = [self getOperationWithMethod:method withRequest:request andCallback:callback]; 

    [operation start]; 
+0

尝试%U。他们的枚举在技术上没有签名。 – CodaFi 2013-03-16 19:07:17

+0

@CodaFi调试:网络覆盖4294967295 – Pion 2013-03-16 20:51:55

+0

我的不好,我看了一个老版本的枚举。 – CodaFi 2013-03-16 21:26:59

回答

11

假设你正在使用ARC该块可能永远不会被解雇,因为你的httpClient正在就这种方法完成释放。

要解决这个问题,你需要创建httpClient作为strong@property如:

@property (nonatomic, strong) AFHTTPClient *httpClient;