I checked lots of similar questions here, the answers to which do not seem to be a working solution for me. I am reading a formatted File into a string "Substring #1: Hello World!; Substring #2: My name is Tom; Substring #X: This is another substring"
. I need to find an index of Substring #1
to print its content (Hello World!
), later in code I would need to print the content of Substring #2
(My name is Tom
) and so on.
So far I have tried:
String.index(of: subString)
- Xcode error:
Cannot convert value of type 'String' to expected argument type 'Character'
String.firstIndex(of: subString)
- Xcode error: `
Cannot convert value of type 'String' to expected argument type 'Character'
What would the efficient way of doing this?