Get values from a textfield array

前端 未结 4 451
难免孤独
难免孤独 2021-01-29 10:07

I would like to access the values of my textfield array but confused as the array I created is with tags. So anyone knows how to get the value of the list (array) I created?

4条回答
  •  伪装坚强ぢ
    2021-01-29 10:28

    1.Your collection Outlet will be something like this

        @IBOutlet var textFields: [UITextFields]!
    

    2. Sort it by tag

        textFields.sort { $0.tag < $1.tag}
    

    3. Use for loop to get value from array and concatenate it

        var string = ""
    
        for item in textFields {
          string += item.text
        }
    

提交回复
热议问题