UITextField.selectAll provides inconsistent behavior

Originator:wishie
Number:rdar://37235692 Date Originated:
Status: Resolved:
Product:iOS + SDK Product Version:
Classification:Bug Reproducible:Always
 
Summary:

Calling `selectAll(nil)` on a UITextField within its delegates textFieldDidBeginEditing provides erratic behavior. It seems to work pretty consistently the 1st time, but not subsequently.

I've provided a sample project which reproduces the issue.

Steps to Reproduce:

1. Create a UITextField
2. Create a delegate for it which calls textField.selectAll(nil) in its textFieldDidBeginEditing method
3. Add a way to resign first responder
4. Click the text field to make it the first responder, and select all text


Expected Results:

It works the first time the textfield is selected, but not subsequent times.

Actual Results:

The textfield should be in focus and all text should be selected.

Version/Build:

iOS 11.2.5
Xcode Version 9.2 (9C40b)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!