I'm going crazy with substrings in Swift. I need to get the actual index of a "string" inside another string to determine the range of my final output.
Any ideas? Thanks
I'm going crazy with substrings in Swift. I need to get the actual index of a "string" inside another string to determine the range of my final output.
Any ideas? Thanks
let yourString = "loremipsumSTRINGdolor" as NSString
let range: NSRange = yourString.rangeOfString("STRING")
let lenght = range.length
let location = range.location
This should do.
EDIT: Fix.