Reputation: 6291
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
Upvotes: 1
Views: 2898
Reputation: 984
let yourString = "loremipsumSTRINGdolor" as NSString
let range: NSRange = yourString.rangeOfString("STRING")
let lenght = range.length
let location = range.location
This should do.
EDIT: Fix.
Upvotes: 3