Comment ajouter un Champ texte pour UIAlertController en Swift

Je suis en train de montrer un UIAlertController avec un UITextView. Quand j'ai ajouter la ligne:

    //Add text field
    alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in
    }        

- Je obtenir un Runtime erreur:

erreur fatale: de façon inattendue trouvé nulle, tandis que d'ôter une valeur Facultative

    let alertController: UIAlertController = UIAlertController(title: "Find image", message: "Search for image", preferredStyle: .Alert)

    //cancel button
    let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
        //cancel code
    }
    alertController.addAction(cancelAction)

    //Create an optional action
    let nextAction: UIAlertAction = UIAlertAction(title: "Search", style: .Default) { action -> Void in
        let text = (alertController.textFields?.first as! UITextField).text
        println("You entered \(text)")
    }
    alertController.addAction(nextAction)

    //Add text field
    alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in
        textField.textColor = UIColor.greenColor()
    }
    //Present the AlertController
    presentViewController(alertController, animated: true, completion: nil)

Ce qui est présenté à l'intérieur de mon ViewController via un IBAction.

J'ai téléchargé le code de ici et il fonctionne très bien. J'ai copié et collé cette méthode dans mon code et il se casse. La présence de auto sur la dernière ligne n'a pas d'impact.

  • UITextField, plutôt que de UITextView ?