Skip to content

Instantly share code, notes, and snippets.

@gaaamii
Created January 1, 2015 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaaamii/a4adefb49e132edcb55c to your computer and use it in GitHub Desktop.
Save gaaamii/a4adefb49e132edcb55c to your computer and use it in GitHub Desktop.
SwiftとXcode6で作るカウンターアプリ
import UIKit
class ViewController: UIViewController {
@IBOutlet var counter: UILabel!
var num:Int = 0
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func updateCounter(num: Int) {
counter.text = String(num)
}
@IBAction func plusOne(sender: AnyObject) {
num += 1
updateCounter(num)
}
@IBAction func minusOne(sender: AnyObject) {
num -= 1
updateCounter(num)
}
@IBAction func resetCounter(sender: AnyObject) {
num = 0
updateCounter(num)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment