So as the title suggest, I have a series of UITextFields that the user will input integers (even though it will be saved as a string) and I would like to simply find the sum of those integers. I have collected the 9 TextFields together in an IBOutletCollection, so they are already in an array, and I would like to convert the independent values into Integers, and find the sum of those numbers to display back to the user (technically a running total as they enter values).
Here is the code I have… most of the online solutions have led to bugs and errors from past versions of Swift. I am on the current version.
import UIKit
class ViewController: UIViewController {
@IBOutlet var playerScores: [UITextField]!
@IBOutlet weak var front9Total: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// intPlayerScores = playerScores.map {Int($0)!}
// Do any additional setup after loading the view.
}
//let intPlayerScores = Array<Int>()
}