当我呼叫服务时,它会给出以下错误响应。
我做了google并重新启动了Xcode和模拟器。它不适合我。即使在设备中,我也面临同样的问题。任何人都可以帮助我。
服务电话:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?%@", urlString,paramsString]];
theRequest = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:120.0];
if (paramsString!=nil)
{
NSString *msgLength = [[NSString alloc]initWithFormat:@"%lu",(unsigned long)[paramsString length]];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
}
[theRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[theRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[theRequest setValue:[NSString stringWithFormat:@"authToken=%@",self.authToken] forHTTPHeaderField:@"Cookie"];
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection)
{
self.receivedData=[[NSMutableData alloc] init];
}
错误:
Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo=0x7c3770a0 {NSErrorFailingURLStringKey=serviceUrl, _kCFStreamErrorCodeKey=-4, NSErrorFailingURLKey=serviceUrl, NSLocalizedDescription=The network connection was lost., _kCFStreamErrorDomainKey=4, NSUnderlyingError=0x79769170 "The network connection was lost."}