Skip to content

Instantly share code, notes, and snippets.

@kenji272
Created April 21, 2015 16:27
Show Gist options
  • Save kenji272/1943d4fe6362feb4d9da to your computer and use it in GitHub Desktop.
Save kenji272/1943d4fe6362feb4d9da to your computer and use it in GitHub Desktop.
【課題】Part4 数字をカウントアップするアプリを作る
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var targetTextField: UITextField!
@IBOutlet weak var resultLabel: UILabel!
var resultCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
// ラベル初期化
self.resultLabel.text = "0"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
// インクリメント処理
@IBAction func increment(sender: AnyObject) {
self.resultCount++
self.resultLabel.text = "\(self.resultCount)"
}
// クリア処理
@IBAction func clear(sender: AnyObject) {
self.resultCount = 0
self.resultLabel.text = "0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment