title: Running Pace Calculator in Swift
body: <p>I'm a complete newbie to Swift. I have created a running pace calculator as experiment in Playground and it works perfectly, but I struggle to figure out how to connect it to a UI. </p>
  
  <p>Things in particular I struggle with currently:</p>
  
  <ul>
  <li>Casting a text string to an Int label</li>
  <li>Does the function that does the calculation go in the IBAction?</li>
  </ul>
  
  <p><strong>Playground Code</strong></p>
  
  <pre><code>import UIKit
  
  func PaceCalculator (minutes:Double, seconds:Double, distance:Double) -&gt; Double{
      return ((minutes*60) + seconds) / distance
  }
  
  var paceInSeconds = PaceCalculator(28, 26, 10.1)
  var paceInMinutes = paceInSeconds / 60
  var roundedMinutes = Double(floor(paceInMinutes))
  var decimalSeconds = paceInMinutes - roundedMinutes
  var intPace = Int(floor(roundedMinutes))
  var seconds = Int(floor(decimalSeconds * 60))
  
  println("Your average pace is \(intPace):\(seconds)/km")
  </code></pre>
  
  <p><strong>Incomplete Swift Code</strong></p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
      @IBAction func calculatePaceButton(sender: UIButton) {
  
      }
  
      @IBOutlet weak var minutesTextField: UITextField!
      @IBOutlet weak var distanceTextField: UITextField!
      @IBOutlet weak var paceLabel: UILabel!
  
  }
  </code></pre>
  
  <p><strong>Storyboard</strong></p>
  
  <p><img src="https://i.stack.imgur.com/Z9Soo.png" alt="enter image description here"></p>
  
  <p><strong>Disclaimer:</strong> I have no programming experience either. So be gentle on the jargon and explanation.)</p>