ios – The best way to seize maintain of a UITextField’s placeholder outdoors of the closure it was declared in?

I’ve created an alert view that exhibits up with a textual content subject. I need to have the ability to change the placeholder of the textual content subject to “Enter one thing right here” when consumer clicks on the “Add Merchandise” button if the string entered is empty. Any thought methods to obtain this impact?

That is my code:

import UIKit

class TodoListViewController: UITableViewController {

    var itemArray = ["A", "B", "C"]
    override func viewDidLoad() {
        self.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white, .font: UIFont.systemFont(ofSize: 25, weight: .bold)]
        self.navigationController?.view.backgroundColor = UIColor(crimson: 0.29, inexperienced: 0.63, blue: 0.82, alpha: 1)
    //MARK: - TableView DataSource Strategies
    override func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
        return itemArray.depend

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "ToDoItemCell", for: indexPath)
        cell.textLabel?.textual content = itemArray[indexPath.row]
        return cell
    //MARK: - TableView Delegate Strategies
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if tableView.cellForRow(at: indexPath)?.accessoryType == .checkmark{
            tableView.cellForRow(at: indexPath)?.accessoryType = .none
        } else {
            tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark
        tableView.deselectRow(at: indexPath, animated: true)
    //MARK: - Add New Objects
    @IBAction func addButtonPressed(_ sender: UIBarButtonItem) {
        var textField = UITextField()
        let alert = UIAlertController(title: "Add New Merchandise:", message: "", preferredStyle: .alert)
        let motion = UIAlertAction(title: "Add Merchandise", type: .default) { motion in
            if textField.textual content != "" {
                self.itemArray.append(textField.textual content!)
            } else {
                //change title of placeholder right here
        alert.addTextField { alertTextField in
            alertTextField.placeholder = "Create new merchandise"
            textField = alertTextField
        current(alert, animated: true, completion: nil)