I am wondering how to let my to-do-list be the same after the app is closed. In my code I am declaring an array right in the beginning and I want to know how I can save it updated for the user, after he restarted the App. I searched the web for some answers but only found old ideas about creating entities in storyboard. And I am pretty sure, that by now there has to be something more beautifully than adding it manually.

How can I save the array when it is getting updated, so it won't get lost after an app restart?

My Code:

```
import UIKit

var checklist = ["Item 1", "Item 2"]

class ChecklistViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource{

var newChecklistItemString: String?
var alertInputTextField: UITextField?

@IBOutlet weak var myTableView: UITableView!

let mainStoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

var selectedChecklist: [String] = []

public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    return (checklist.count)
}

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = UITableViewCell(style: UITableViewCell.CellStyle.default, reuseIdentifier: "cell")
    cell.textLabel?.font = UIFont.boldSystemFont(ofSize: 18.0)
    cell.textLabel?.text = checklist[indexPath.row]

    if selectedChecklist.contains(checklist[indexPath.row]) {
        cell.accessoryType = .checkmark
    }
    else{
        cell.accessoryType = .none
    }

    return cell
}

// checkmarks when tapped
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark
    selectedChecklist.append(checklist[indexPath.row])
    tableView.deselectRow(at: indexPath, animated: true)
}

func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        let value = checklist.remove(at: indexPath.row)
        myTableView.reloadData()
    }
}

override func viewDidAppear(_ animated: Bool) {
    myTableView.reloadData()
}

override func viewDidLoad() {
    super.viewDidLoad()

    addSlideMenuButton()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

@IBAction func addNewObject(_ sender: Any) {

    let alert = UIAlertController(title: "New Item", message: nil, preferredStyle: .alert)
    alert.addTextField { (alertInputTextField) in
        alertInputTextField.autocapitalizationType = .sentences
    }

    alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: { (action) in
        self.dismiss(animated: true, completion: nil)
    }))

    alert.addAction(UIAlertAction(title: "Add", style: .default, handler: { (action) in

        let textf = alert.textFields![0] as UITextField

        if(textf.text != "")
        {
            checklist.append(textf.text!)
        }
        self.myTableView.reloadData()

    }))

    self.present(alert, animated: true, completion: nil)

   }
}

```