我必须在我的应用程序中从服务器加载所有必需的详细信息。例如;我想从以下网址加载国家/地区详细信息。
https://sub.domain.com//members/phone/XML_list_countries.php
但我收到了以下错误。但是同样的请求在模拟器中工作。
ERROR
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x3b8d10 {NSErrorFailingURLStringKey=https://secure.nymgo.com//members/softphone/XML_list_countries.php, NSErrorFailingURLKey=https://secure.nymgo.com//members/softphone/XML_list_countries.php, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x3b5090 "The request timed out."}
CODE
NSURL *url=[NSURL URLWithString:@"https://secure.nymgo.com//members/softphone/XML_list_countries.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];
NSURLConnection *_connection = [[NSURLConnection alloc] initWithRequest:_request delegate:self];
if(!_connection){
NSLog(@"Can not make this request.");
}
我已经实现了所有必需的delegate
方法。
注意:我的设备正在使用代理设置在Wifi中工作。
我不知道出了什么问题。请帮我解决这个问题。
答案 0 :(得分:0)
你有没有实施:
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
另请参阅this SO post。
您也可以使用ASIHTTPRequest
框架。
答案 1 :(得分:0)
我在不同的iPhone 3G
和iPhone 4
设备中测试了相同的代码。它工作正常。
注意:我在谷歌搜索了很多。我得到了很多结果。其中一个结果就是“某些iPhone 3G
不支持HTTPS
。所以我决定在不同的设备上测试它。