Create a gist now

Instantly share code, notes, and snippets.

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