I want to convert the index of a letter contained within a string to an integer value. Attempted to read the header files but I cannot find the type for Index,
Index
Swift 4
var str = "abcdefg" let index = str.index(of: "c")?.encodedOffset // Result: 2
Note: If String contains same multiple characters, it will just get the nearest one from left
var str = "abcdefgc" let index = str.index(of: "c")?.encodedOffset // Result: 2