2013-03-16 53 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;