swiftで指定したURLの閲覧をするWeb Viewアプリを作っているのですが、loadURL()関数にて、下記のようなエラーが出てしまい困っています。
[エラーコード]
'NSURL' is not implicitly convertible to 'URL'; did you mean to use 'as' to explicitly convert?
[ソースコード]
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var webview: UIWebView! var url:String = "https://www.google.co.jp" func loadURL(){ let requestURL = NSURL(string: url) let request = NSURLRequest(URL: requestURL!) webview.loadRequest(request) } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. loadURL() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. }
}
[開発環境]
Xcode 8.2
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/17 05:39