I want gave a custom Index to my code which that means the custom String/Character to read unicodeScalars for that String in that spacial position, for example this down code works with
string.startIndex
but I could not change it the index that I wanted, even the codes gave error in runtime for string.endIndex
So I need help, right now this down code works just for index zero of string, for example I want this work for index = 1 that means B, how can I do this?
let string: String = "ABC"
let UInt32Value: UInt32 = string.unicodeScalars[string.startIndex].value
print(UInt32Value)
Update: you can replace string.startIndex
with customIndex
let index: Int = 1
let customIndex: String.Index = string.index(string.startIndex, offsetBy: index)
Still need help to know why string.endIndex
not working!?!