2011-07-07 49 views
1

我使用下面的代碼使用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]; 

,當我運行該項目得到

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 
{ 
    NSLog(@"ERROR with theConenction %@",error); 


} 

錯誤follwing錯誤如下

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

此錯誤是因爲數據連接不可用。 – iAmitWagh

+0

它是否與另一個URL(例如apple.com)一起工作? – teriiehina

回答

0

如果您正在調試並且您的超時設置較低,則可能會遇到此問題。嘗試增加超時或運行沒有斷點。