I made an iOS application with Xcode and Swift.
I want to open certain hyperlinks in the Safari browser, others in the WebView itself.
To achieve this, I will need to check when the hyperlink is clicked.
This is the code that I still have:
import UIKit
class PushViewController: UIViewController, UIWebViewDelegate {
@IBOutlet var openpushmessage: UIWebView!
var weburl:String = "http://www.example.com"
override func viewDidLoad() {
super.viewDidLoad()
let url: NSURL = NSURL(string: weburl)!
let requestURL: NSURLRequest = NSURLRequest(URL: url)
openpushmessage.loadRequest(requestURL)
}
override func webView(_ webView: UIWebView, shouldStartLoadWithRequest request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if navigationType == .linkClicked
{
print("You clicked a hypelink!")
}
return true
}
}
The code in viewDidLoad()opens downloading the main URL ( http://www.example.com ) from my server. It works great.
override fun webView[…]You must determine if the hyperlink is clicked, and then print("You clicked a hypelink!").
But unfortunately, I get the following errors:

What am I doing wrong? How to get rid of these errors?
user7128548
source
share