English 中文(简体)
连接到 www.google.com 时出错, 使用 NSC 连接
原标题:I got an error when connect to www.google.com use NSConnection

使用 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";
}
最佳回答

尝试 NSString *urkString = @ "http://www.google.com" ; 您需要在每个 URL 方案中设置 URL 方案 。 即 http:// /code > 或 https://

问题回答

暂无回答




相关问题
连接到 www.google.com 时出错, 使用 NSC 连接

使用NSConnection连接到 www.google.com 时, 我有一个错误。 我找不到原因 。 任何帮助都会感激不尽 。 NSString *urkString = @ "www.google.com"; NSURL *url = [NSURL...

Multiple simultaneous NSConnections for web query

When using async download methods and delegates, is it possible to start multiple simultaneous nsconnections and handle them separately as each query completes? Or, will the system not automatically ...

Error while making SOAP request call in iPhone app

I am trying to make a soap call. It s a very basic call with "Welcome User" output. The return value is in xml format, and I am getting the following error. However I am not sure what this error means....

Best way to do interprocess communication on Mac OS X

I m looking at building a Cocoa application on the Mac with a back-end daemon process (really just a mostly-headless Cocoa app, probably), along with 0 or more "client" applications running locally (...