Right now my code prints the struct that was entered, but it can only print the last individual entry entered. It can only store 1 entry. How can I store and print every entry in the struct.
import UIKit
class ViewController: UIViewController {
@IBOutlet var c: UITextField!
@IBOutlet var a: UITextField!
@IBOutlet var b: UITextField!
var contacts: [Person] = []
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func press(_ sender: Any) {
contacts.append(Person(name: a.text!, surname: b.text! , phone: Int(c.text!)!))
print(self.contacts.description)
}
struct Person {
var name: String
var surname: String
var phone: Int
}}