Search code examples
iosiphoneswiftios7swift2

How convert String.UTF8View.Index to String.CharacterView.Index?


I'm handling with String in swift.But when I want to convert String.UTF8View.Index to String.CharacterView.Index,I got some trouble.Anyone knows how to do?Thanks in advance!


Solution

  • Use the following init function:

    String.Index.init(utf8Index: UTF8Index##UTF8Index#>, within: <#T##String#>)
    

    You must user String as parameter in this function.