So I have this swift code:
func didReceiveResponse(response:String) {
...
let substr = response[11...]
By my interpretation, substr
should be a Substring referencing all characters after index 11 in the response string.
What actually happens is this compiler error:
Cannot subscript a value of type 'String' with an index of type 'CountablePartialRangeFrom<Int>'
This seems like it should be obvious, can anyone help please?
Whoops. Seems I needed to just do this:
let idx = response.index(response.startIndex, offsetBy: 11)
let substr = response[idx...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With