NSRange to Range

How can I convert NSRange to Range<String.Index> in Swift?

I want to use the following UITextFieldDelegate method:

    func textField(textField: UITextField!,
        shouldChangeCharactersInRange range: NSRange,
        replacementString string: String!) -> Bool {

textField.text.stringByReplacingCharactersInRange(???, withString: string)

enter image description here

16 Answers
16

Leave a Comment