0
我想用swift構建一個iOS瀏覽器應用程序(請記住我是新來的swift),並在我的代碼中出現錯誤:實例成員websitetext不能用於'ViewController4'類型這是我遇到錯誤的唯一行。這個錯誤的其他論壇都沒有解釋這是一個新的swift的人。這是我的代碼。謝謝!我得到的錯誤:實例成員websitetext不能用於類型'ViewController4
import UIKit
class ViewController4: UIViewController, UITextFieldDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let requestURL = NSURL(string:website)
let request = NSURLRequest(URL: requestURL!)
webView.loadRequest(request)
// Do any additional setup after loading the view.
}
let website = (string:websitetext.text) //"https://google.com" line error: Instance member websitetext can not be used on type 'ViewController4
@IBOutlet weak var webView: UIWebView!
@IBOutlet weak var websitetext: UITextField!
@IBAction func back(sender: AnyObject) {
if webView.canGoBack {
webView.goBack()
}
}
@IBAction func gohome(sender: AnyObject) {
self.performSegueWithIdentifier("webtohome", sender: self)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
那條線應該有一個'NSURL'嗎? (另外,該線應該在某個功能內嗎?) –