1

When I add one or more textField into UIAlertController the app freezes, once I deleted the textFields it works perfectly fine.

Xcode 11 beta 5 running on Mojave 10.14.6

@IBAction func addRecipeBtnHandler(_ sender: Any) {
    let alert = UIAlertController(title: "Add new recipe", message: nil, preferredStyle: .alert)

    alert.addTextField { textField in
        textField.placeholder = "title"
    }
    alert.addTextField { textField in
        textField.placeholder = "description"
    }

    let action = UIAlertAction(title: "Add", style: .default) { alertAction in
        let title = alert.textFields?.first?.text ?? ""
        let description = alert.textFields?.last?.text ?? ""

        let recipe = Recipe(title: title, description: description)
        self.recipes.append(recipe)

        self.updateSnapshot()
    }
    alert.addAction(action)

    DispatchQueue.main.async {
        self.present(alert, animated: true)
    }
}
Soufian Hossam
  • 487
  • 5
  • 16

1 Answers1

3

I had the same problem with beta 6. Switching to a new emulator (i.e. a device I hadn't used before) temporarily solved the problem. Seems like a bug in Xcode to me. Hardware > Erase all content and settings also temporarily fixes the emulator for a while. The bug then reappears after some time.

Fabian Streitel
  • 2,702
  • 26
  • 36