使用NSURLConnection时出错? [英] Error using NSURLConnection?
本文介绍了使用NSURLConnection时出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码
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];
当我运行项目时出现以下错误
and when I run the project get follwing error in
-(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."}
推荐答案
http://newdev.objectified.com/timvaughn/index .php?option = com_objmobadaptor 似乎需要身份验证。你有没有实现
http://newdev.objectified.com/timvaughn/index.php?option=com_objmobadaptor seems to need authentication. Did you implement
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
?如果您不进行身份验证,请求将超时并导致您的错误。
? If you don't authenticate, the request will timeout and that causes your error.
这篇关于使用NSURLConnection时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文