My code below submits ints to an array the problem is when the user segues to another view controller and then segues back to the original view controller and tries to submit more ints it saves over the original ints that where already saved. EXAMPLE VC1 USERS SUBMITS 1,2 THEN USER GOES TO VC2 USER RETURNS TO VC1 AND SUBMITS 3. WHAT IS PRINTED OUT IS JUST 3. NOT 1,2, AND 3.
import UIKit
class ViewController: UIViewController {
@IBOutlet var txt: UITextField!
var arrayOfInt = [Int]()
@IBAction func submit(_ sender: Any) {
if let text = txt.text {
if let number = Int(text){
arrayOfInt.append(number)
}}}
}