Created
January 1, 2015 06:42
-
-
Save gaaamii/a4adefb49e132edcb55c to your computer and use it in GitHub Desktop.
SwiftとXcode6で作るカウンターアプリ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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