'subscript' is unavailable: cannot subscript String with a CountableClosedRange, see the documentation comment for discussion

前端 未结 8 852
谎友^
谎友^ 2021-01-31 13:57

In Swift 4, I\'m getting this error when I try to take a Substring of a String using subscript syntax.

\'subscript\' is unavaila

8条回答
  •  面向向阳花
    2021-01-31 14:40

    You could just convert your string to an array of characters...

    let aryChar = Array(myString)
    

    Then you get all the array functionality...

提交回复
热议问题