gpt4 book ai didi

nsconnection - 使用 NSConnection 连接到 'www.google.com' 时出现错误

转载 作者:行者123 更新时间:2023-12-04 16:35:31 25 4
gpt4 key购买 nike

使用 NSConnection 连接到“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 Code=-1002 "unsupported URL" UserInfo=0x4c9feb0 {NSErrorFailingURLStringKey=www.google.com, NSErrorFailingURLKey=www.google.com, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x4c9fdf0 "unsupported URL"}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
_endSystemDate = [self getSystemDate];
_receivedData = nil;
_connection = nil;
_status = @"Completed";
}

最佳答案

试试 NSString *urkString = @"http://www.google.com";您需要为每个 URL 设置 URL Scheme。即 http://https://

关于nsconnection - 使用 NSConnection 连接到 'www.google.com' 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10749687/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com