0

The answer in this question: How do I check if a string contains another string in Swift?

No longer works.

var string = "hello Swift"

if string.rangeOfString("Swift") != nil{
    println("exists")
}

Will get you:

error: value of type 'String' has no member 'rangeOfString'

What is the new way to do this?

Community
  • 1
  • 1
Victor Lin
  • 288
  • 1
  • 3
  • 10

1 Answers1

5

Import Foundation and you will be able to call rangeOfString.

Gary Makin
  • 3,109
  • 1
  • 19
  • 27
  • indeed I was working in Playground, and could not get the rangeOfString method to work initially, but after I imported Foundation all went smooth. – IamMashed Dec 25 '15 at 17:33