1

我正在从头开始构建一个 Web 浏览器,除了最重要的事情之外,大多数东西都可以正常工作。浏览器将因错误 sigabrt 而失败,虽然我是 iPhone 编程的新手,但我很确定这意味着我没有正确发送 URL。

这是通过按下按钮加载网页的代码。

- (IBAction)getURLButton:(NSString *)aString {
NSURL *URL = [NSURL URLWithString:aString];
NSURLRequest *URLRequest = [NSURLRequest requestWithURL:URL];
BOOL load = [addressBar webView: (goButton) shouldStartLoadWithRequest:URLRequest navigationType:UIWebViewNavigationTypeFormSubmitted];
if (load) {
    error = nil;
    [goButton loadRequest:URLRequest];
    //currentURLString = [UIWebView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
    //It's not in Xcode? It continues to get an error after I write the above statement.
} else {
    NSString *message = NSURLErrorFailingURLErrorKey;
    NSLog(@"%@",message);
}

}

这是错误消息:

2013-02-14 16:49:28.724 WebBrowser[1265:c07] -[ViewController getURL:]: unrecognized selector sent to instance 0x716f1d0
2013-02-14 16:49:28.727 WebBrowser[1265:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController getURL:]: unrecognized selector sent to instance 0x716f1d0'

我知道某处的错误,我只是不知道在哪里。帮助?

4

1 回答 1

-1
 2013-02-14 16:49:28.724 WebBrowser[1265:c07] -[ViewController getURL:]: unrecognized selector sent to instance 0x716f1d0
 2013-02-14 16:49:28.727 WebBrowser[1265:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController getURL:]: unrecognized selector sent to instance 0x716f1d0'

如果您看到您的异常,您正在调用getURL:,因为您的方法名称是getURLButton:

于 2013-02-15T00:14:54.190 回答