我在youtube上关注了一个关于Swift的Hello World程序的在线教程。即使我输入代码就像教程中的代码一样,它直到给我一个调试错误(绿色错误)。我研究了这样的问题,但代码很复杂,而且是我的头脑。通常我在java中编码,但我一直想开发移动版。无论如何,如果你能告诉我: 1.错误意味着什么。 2.我如何解决它。 3.我怎样才能防止这样的错误。
NameLabel.text ="嗨(nameTextField.text)"是我得到错误的行。 这是我的代码:
import UIKit
class ViewController: UIViewController {
@IBOutlet var NameLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func HelloWorldAction(nameTextField: UITextField) {
NameLabel.text = "Hi \(nameTextField.text)"
}
}
答案 0 :(得分:0)
nameTextField是@IBAction。它是@IBOutlet。 我做了一个按钮,它占用了动作。我有一切工作。
@IBAction func button(sender: UIButton!) {
NameLabel.text = "Hi \(namedTextField.text)"
}