我在製作簡單的計數器計數器應用程序時遇到困難。我已經把代碼,但當我點擊「運行模擬」,它總是給出錯誤信息。誰能幫我找到我的錯誤?謝謝。在iOS中製作基本的計數器計數器
我的代碼如下圖所示:
import UIKit
class ViewController: UIViewController {
var counter: Int!
@IBOutlet weak var Display: UILabel!
func updateDisplay() {
Display.text = String(counter)
}
override func viewDidLoad() {
super.viewDidLoad()
counter = 0
updateDisplay()
// 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 PlusButton(sender: AnyObject) {
counter = counter + 1
updateDisplay()
}
@IBAction func MinusButton(sender: AnyObject) {
counter = counter - 1
updateDisplay()
}
@IBAction func ClearButton(sender: AnyObject) {
counter = 0
updateDisplay()
}
}
這裏是在Xcode https://www.facebook.com/photo.php?fbid=10204747519271053&set=pcb.10204747520111074&type=1&theater
這裏的外觀 https://www.facebook.com/photo.php?fbid=10204747519351055&set=pcb.10204747520111074&type=1&theater
它給出了什麼錯誤以及在哪一行? –
https://www.facebook.com/photo.php?fbid=10204747519351055&set=pcb.10204747520111074&type=1&theater它不顯示任何「!」跡象,但當我點擊「運行模擬」,它不想工作。 –
任何我可以看到項目文件的地方? Github上? – Usernumbernine