Skip to content

Instantly share code, notes, and snippets.

@masakid
Last active August 29, 2015 14:16
Show Gist options
  • Save masakid/66aaa3f46deffe8f6c56 to your computer and use it in GitHub Desktop.
Save masakid/66aaa3f46deffe8f6c56 to your computer and use it in GitHub Desktop.
lesson1+
//
// ViewController.swift
// Problem_part1
//
import UIKit
class ViewController: UIViewController {
@IBOutlet var textField: [UITextField]!
@IBOutlet weak var resultLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func pressCalcButton(sender: AnyObject) {
//配列作成、reduceでそれぞれ足し合わせる
self.resultLabel.text = "\(self.textField.reduce(0){ $0 + ($1.text.toInt() ?? 0)})"
}
@IBAction func didEndOnExit(sender: AnyObject) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment