【发布时间】:2013-03-16 18:17:50
【问题描述】:
我使用最新的 AFNetworking 源,但可达性对我不起作用,它永远不会触发可达性块,[httpClient networkReachabilityStatus] 总是返回 -1。 SystemConfiguration/SystemConfiguration.h 包含在 .pch 中
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];
【问题讨论】:
-
试试 %u。他们的枚举在技术上是未签名的。
-
@CodaFi 调试:网络到达 4294967295
-
我的错,我查看了一个旧版本的枚举。
-
如果您将设备打开飞行模式,该块也不会触发?您可能还想尝试为您的 httpClient 创建一个强大的@property,以确保它不只是在块被调用之前被释放。
-
@KeithSmiley httpClient 必须在属性中才能使其工作。谢谢 !现在,我必须重新设计我的 API 类 :)
标签: ios objective-c afnetworking