我正在使用以下代码
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:listUrl]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:180.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
xmlData=[[NSMutableData alloc]init];
当我运行项目时,
中出现以下错误-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"ERROR with theConenction %@",error);
}
错误如下
2011-07-07 16:17:12.343 Tim Vaughn[722:707] ERROR with theConenction Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x1b8b10 {NSErrorFailingURLStringKey=http://newdev.objectified.com/timvaughn/index.php?option=com_objmobadaptor, NSErrorFailingURLKey=http://newdev.xxxxx.com/xxxxxx/index.php?option=com_objmobadaptor, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x1bb610 "The request timed out."}
答案 0 :(得分:1)
http://newdev.objectified.com/timvaughn/index.php?option=com_objmobadaptor似乎需要身份验证。你有没有实现
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
?如果您不进行身份验证,请求将超时并导致您的错误。
答案 1 :(得分:0)
如果您正在调试并且超时设置为低,则可能会遇到此问题。尝试增加超时或没有断点运行。