我试图通过segue附加到数组:
@IBOutlet weak var addTextTextField: UITextField!
@IBAction func addTextButton(_ sender: UIButton)
{
performSegue(withIdentifier: "addTextSegue", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
let mainViewController = segue.destination as! MainViewController
mainViewController.array.append(addTextTextField.text!)
}
它只附加到数组一次,下次我尝试时,它会覆盖最后一个条目。这是什么原因?