Created
May 9, 2015 13:40
-
-
Save kenji272/fd82835a0223a34132e5 to your computer and use it in GitHub Desktop.
【課題】Part7 足し算と引き算を行うタブアプリ
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 AdditionViewController: UIViewController { | |
@IBOutlet weak var target1Text: UITextField! | |
@IBOutlet weak var target2Text: UITextField! | |
@IBOutlet weak var resultLabel: UILabel! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
} | |
@IBAction func Add(sender: AnyObject) { | |
let target1 = (self.target1Text.text as NSString).integerValue | |
let target2 = (self.target2Text.text as NSString).integerValue | |
// 足し算を行う | |
self.resultLabel.text = "\(target1 + target2)" | |
// キーボードを隠す | |
self.target1Text.resignFirstResponder() | |
self.target2Text.resignFirstResponder() | |
} | |
} |
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 SubtractionViewController: UIViewController { | |
@IBOutlet weak var target1Text: UITextField! | |
@IBOutlet weak var target2Text: UITextField! | |
@IBOutlet weak var resultLabel: UILabel! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
} | |
@IBAction func subtract(sender: AnyObject) { | |
let target1 = (self.target1Text.text as NSString).integerValue | |
let target2 = (self.target2Text.text as NSString).integerValue | |
// 引き算を行う | |
self.resultLabel.text = "\(target1 - target2)" | |
// キーボードを隠す | |
self.target1Text.resignFirstResponder() | |
self.target2Text.resignFirstResponder() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment