Swift 3: cannot convert value of type 'String.Index' to expected argument type Range (aka 'Range<String.CharacterView.Index>')
<p>I'm trying to replace a substring with another substring but I'm getting this error:</p>

<pre><code> cannot convert value of type 'String.Index' (aka 'String.CharacterView.Index') to expected argument type 'Range&lt;String.Index&gt;' (aka 'Range&lt;String.CharacterView.Index&gt;')
</code></pre>

<p>Here is my Code:</p>

<pre><code>// This are the position of the substrings:
let rangeOne = strToSort.index(strToSort.startIndex, offsetBy: (i-1))
let rangeTwo = strToSort.index(strToSort.startIndex, offsetBy: (i))

Here is where I try to make the replacement:


strToSort = strToSort.replacingCharacters(in: rangeOne, with: strToSort.substring(with: rangeTwo))
</code></pre>

<p>But I'm getting this error:</p>

<p><a href="https://i.stack.imgur.com/WGGjR.png" rel="nofollow"><img src="https://i.stack.imgur.com/WGGjR.png" alt="enter image description here"></a></p>

<p>Any of you knows what I'm doing wrong or a work around this?</p>

<p>I'll really appreciate your help</p>