Using Array and let

  @IBOutlet var nameHere: UITextField!


    @IBOutlet var sumHere: UILabel!



    @IBAction func submit(_ sender: Any) {


        let (a, b, c, d, e, f, g, h, i) = (1, 2, 3, 4, 5, 6, 7, 8, 9)

        let emptyArray: [Int] = []

        var sum = 0

        for number in emptyArray {

            sum += number


this works when I enter items in the array manually or in playground, but when I try and build project I cant get values to appear in sumHere.  Is there a problem with sumHere being a textfield?  All I am trying to do is enter text in nameHere and output sum in SumHere.  thanks for any advice.

Powered by WPeMatico


You may also like...

Comments are closed.