Check if string contains string

 Problem

I want to check if a string contains another string



 Recipe


// String literal
let s = "Hello World"

// Check if it contains 'Hello'

if s.rangeOfString("Hello") != nil {
    print("Yes it contains 'Hello'")
}

				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground