Xcode 手动下载url,但不使用NSURLRequest
我想我的问题和这个一样,但我不太明白答案 我的应用程序要求用户输入包含Xcode 手动下载url,但不使用NSURLRequest,xcode,url,Xcode,Url,我想我的问题和这个一样,但我不太明白答案 我的应用程序要求用户输入包含.pbn文件的网站的URL。但是,当在我的应用程序的文本字段中输入相同的URL时,手动工作的URL不起作用。在我的示例中,self.urlNameInput.text是http://www.atlantaduplicatebridgeclub.com/scorepost/2013/01/20130126ana.pbn并且无法识别URL NSURLRequest *theRequest=[NSURLRequest request
.pbn
文件的网站的URL。但是,当在我的应用程序的文本字段中输入相同的URL时,手动工作的URL不起作用。在我的示例中,self.urlNameInput.text
是http://www.atlantaduplicatebridgeclub.com/scorepost/2013/01/20130126ana.pbn
并且无法识别URL
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlNameInput.text] cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
根据是否包含或排除“http://”,我会收到以下错误消息
连接失败!错误-找不到具有指定主机名的服务器
连接失败!错误-不支持的URL www.atlantabridgeclub.com/scorepost/2013/01/20130126ana.pbn这似乎工作正常:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.atlantaduplicatebridgeclub.com/scorepost/2013/01/20130126ana.pbn"]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSString *results = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"Results:%@", results);
}];
是的,在我使用TextField之前,我也成功地使用了以下内容,但是现在我在TextField条目上遇到了问题<代码>NSURLRequest*theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@]http://www.atlantaduplicatebridgeclub.com/scorepost/2013/01/20130126ana.pbn“]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]代码>谢谢。我下载了工作,但我有一个相关的问题。我现在是否可以消除以下委托方法:连接:didReceiveResponse:、连接:didReceiveData:、连接:didFailWithError:和connectionDidFinishLoading:因为您正在使用另一个路由?或者我可以把你的方法和那些委托方法联系起来吗?。