I have a bunch of textFields which content I want to add to a array
I have tried different approaches, and I got it working with this method:
@IBAction func addToArrayTapped(_ sender: UIButton) {
if let fromTextField1 = textField1.text {
array.append(fromTextField1)
}
if let fromTextField2 = textField2.text {
array.append(fromTextField2)
}
if let fromTextField3 = textField3.text {
array.append(fromTextField3)
}
print(array)
}
Is this really the correct way to add content from a textField to a array? It feels a bit complicated.