title: Restrict the input of a textfield in UIAlertController when the user types using swift?
body: <p>I have found this sample code about <strong>how to add the textfield</strong> for the <code>UIAlertController</code> <strong>but I am unable to restrict the the users to enter only 10 characters as a limit</strong>, I have a function to remove the last character when it is go over when <strong>editing changed for a regular textfield</strong> but <strong>unable to check the textfield on the <code>UIAlertController</code></strong>.</p>
  
  <pre><code>//Function to Remove the last character
  
  func trimStr(existStr:String)-&gt;String{
  
      var countExistTextChar = countElements(existStr)
  
      if countExistTextChar &gt; 10 {
          var newStr = ""
          newStr = existStr.substringToIndex(advance(existStr.startIndex,(countExistTextChar-1)))
          return newStr
  
      }else{
          return existStr
      }
  
  }
  
   var inputTextField: UITextField?
  
      //Create the AlertController
      let actionSheetController: UIAlertController = UIAlertController(title: "Alert", message: "Swiftly Now! Choose an option!", preferredStyle: .Alert)
  
      //Create and add the Cancel action
      let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -&gt; Void in
          //Do some stuff
      }
      actionSheetController.addAction(cancelAction)
      //Create and an option action
      let nextAction: UIAlertAction = UIAlertAction(title: "Next", style: .Default) { action -&gt; Void in
  
  
      }
      actionSheetController.addAction(nextAction)
      //Add a text field
      **actionSheetController.addTextFieldWithConfigurationHandler { textField -&gt; Void in
          //TextField configuration
          textField.textColor = UIColor.blueColor()
  
          inputTextField = textField**
  
  
      }
  
      //Present the AlertController
      self.presentViewController(actionSheetController, animated: true, completion: nil)
  </code></pre>
  
  <p>Thank you.</p>