title: Setting Cursor Position of UITextField not working (swift)
body: <p>I went thru this post <a href="https://stackoverflow.com/questions/34922331/getting-and-setting-cursor-position-of-uitextfield-and-uitextview-in-swift">Getting and Setting Cursor Position of UITextField and UITextView in Swift</a> and I'm getting issue is selecting text.</p>
  
  <p>I follow examples in the referred post and I still don't see any result.
  I have created a basic SingleViewApplication with just a UITextField in it.</p>
  
  <p>The Textfield is set to "foobar" in viewDidLoad</p>
  
  <pre><code>    override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
       textField.text = "foobar"   }
  </code></pre>
  
  <p>In @IBAction Editing Did Begin I try to select the whole text using the method described in this post, see below.</p>
  
  <pre><code>@IBAction func EDB(_ sender: UITextField) {
      let startPosition = textField.beginningOfDocument
      let endPosition = textField.endOfDocument
      textField.selectedTextRange = textField.textRange(from: startPosition, to: endPosition  )
  }
  </code></pre>
  
  <p>That I hopped will select all the text in my textField.</p>
  
  <p>It didn't.</p>
  
  <p>I put two breakpoints to display the selected range of my textField on the line
  let startPosition....
  and one the last line
  those breakpoints execute po textField.selectedTextRange! and continue.</p>
  
  <p>it confirms that I effectively change the range of my textField</p>
  
  <blockquote>
    <p>&lt;_UITextKitTextRange: 0x7fa42bb0d140> (6, 0)F</p>
    
    <p>&lt;_UITextKitTextRange: 0x7fa42b922640> (0, 6)F</p>
  </blockquote>
  
  <p>However there is no visible selection on the UI and the cursor stays at the end of my textField.</p>
  
  <p>What am I missing to get the UI showing my selected range ?</p>
  
  <p>Basically I want to preselect a specific range of text of my UItextField when the user enter in edition. </p>