Floyd Resler Floyd Resler - 6 months ago 67
Swift Question

Swift instr or strpos Equivalent

I've searched and searched but can't see to find what the instr or strpos equivalent in Swift is. Just need to see if a string contains a string. How can I do this in Swift?

Answer

Use rangOfString():

if string.rangeOfString("mySubstring") != nil
{
    println("string contains substring")
}
Comments