How to program a UITextField to save as a entry in swift

I have 1 textfields in my application. I can write something in and it works but if I go to the next page all the data is erased. How can the data be saved? I have also attached its class viewcontroller if that helps.

    import UIKit

    class ViewController: UIViewController {

@IBAction func button(sender: AnyObject) {

        let myTextField: UITextField = UITextField(frame: CGRect(x: 100, y: 575, width: 200.00, height: 40.00));
        myTextField.layer.borderColor = UIColor.grayColor().CGColor
        myTextField.layer.borderColor = UIColor.redColor().CGColor
        myTextField.backgroundColor  = UIColor.greenColor()
        myTextField.layer.borderWidth = 1.5
        myTextField.text = "Hello"

override func viewDidLoad() {
    // Do any additional setup after loading the view, typically from a nib.

override func didReceiveMemoryWarning() {
    // Dispose of any resources that can be recreated.


The UITextField has a property called ‘delegate’. Create or extend a type - for example, the view controller containing the text field - so it conforms to ‘UITextFieldDelegate’, and then assign it to that delegate property. The text field will then notify the type (view controller) when certain things happen, assuming you implement the functions the text field is looking for (look at the documentation for UITextFieldDelegate, implement the functions you need). For example, the text field can tell the view controller when the text inside it changes, or when the user presses ‘return’ having finished typing. In your implementation of these functions, you can copy the text field’s text and save it somewhere.