使用 NSConnonction
连接到 www.google.com 时出错 。
我找不到原因 任何帮助都会感激不尽
NSString *urkString = @"www.google.com";
NSURL *url = [NSURL URLWithString:urkString];
NSURLRequest *request = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60];
_connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if(_connection)
{
_receivedData = [[NSMutableData alloc] init];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Cannot connect to the Web site." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
[alertView show];
[alertView release];
}
但它称为这个方法。错误是:
Error Domain=NSURLErrorDomain 代码=-1002 “不支持的 URL” UseInfo= 0x4c9feb0 {NSError FailingURLStringKey=www.google.com, NSerror FailingURLKey=www.google.com, NNS 本地化Description=不支持的 URL, NS suidelineError= 0x4c9ff0 “不支持的 URLStringKey”\/code
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
_endSystemDate = [self getSystemDate];
_receivedData = nil;
_connection = nil;
_status = @"Completed";
}