无法找到NSURLErrorDoman代码= -2000“无法从网络加载”的源

时间:2018-12-13 00:27:30

标签: watchkit nsurlsession

每次我尝试从主机提取数据时,都会在底部显示错误,然后在完成处理程序返回无错误之前出现4-5秒的延迟。我正在使用Xcode,objective-c和WatchOS。有什么想法可以解决这个问题吗?我尝试从iTunes网站上提取数据,但是遇到了同样的问题,因此它不是主机。还尝试了阻止蜂窝电话,但这也无济于事。

NSURLSessionConfiguration *config=[NSURLSessionConfiguration ephemeralSessionConfiguration];
config.allowsCellularAccess=NO;
ephemeral=[NSURLSession sessionWithConfiguration:config];
relay=[NSURL URLWithString:@"http://192.168.1.3/dev/json.php"];

NSURLSessionDataTask *dataTask=[ephemeral dataTaskWithURL:relay completionHandler:^(NSData *data,NSURLResponse *response, NSError *error)
{
   //....
}];
[dataTask resume];

日志错误:

2018-12-12 19:15:39.894127-0500 EdgeValetWatch WatchKit扩展[7118:261614]任务<6666C271-7428-497B-AA16-2742147FCF9F>。<1>加载失败,错误为Error Domain = NSURLErrorDomain Code =- 2000“无法从网络加载” UserInfo = {NSErrorFailingURLStringKey = http://192.168.1.3/dev/json.php,NSErrorFailingURLKey = http://192.168.1.3/dev/json.php,NSLocalizedDescription =无法从网络加载,_NSURLErrorRelatedURLSessionTaskErrorKey =(     “ LocalDataTask <6666C271-7428-497B-AA16-2742147FCF9F>。<1>” ),NSUnderlyingError = 0x7c10e760 {Error Domain = kCFErrorDomainCFNetwork Code = -2000“(null)”},_NSURLErrorFailingURLSessionTaskErrorKey = LocalDataTask <6666C271-7428-497B-AA16-2742147FCF9F>。<1>} [-2000]

0 个答案:

没有答案