NSURL _CFURLRequest]:无法识别的选择器发送到实例0x8d96de0

时间:2013-12-07 03:12:36

标签: ios objective-c uiwebview

我想在uiWebView中显示一个网页,但我的应用程序崩溃了。试图打电话时,应用程序崩溃了

NSURLRequest *urlRequest =[NSURL URLWithString:@"http://www.google.com"];

我收到以下错误消息:

  

2013-12-07 04:06:09.443 Reac [5374:2703] - [NSURL _CFURLRequest]:   无法识别的选择器发送到实例0x8d96de0 2013-12-07   04:06:09.444 Reac [5374:2703] * 由于未被捕获而终止应用   异常'NSInvalidArgumentException',原因:' - [NSURL   _CFURLRequest]:无法识别的选择器发送到实例0x8d96de0'

#import "WebViewController.h"

@interface WebViewController ()

@end

@implementation WebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.webView.delegate=self;
self.allowNavigation=NO;

NSURLRequest *urlRequest =[NSURL URLWithString:@"http://www.google.com"];

[self.webView loadRequest:urlRequest];
}

@end

1 个答案:

答案 0 :(得分:4)

这一行

NSURLRequest *urlRequest =[NSURL URLWithString:@"http://www.google.com"];

需要

NSURLRequest *urlRequest =[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];

您应该先阅读文档或进行简单的搜索