Im trying to ask for some values from a variable. The variable is going to have the description of the weather and i want to ask for specific words in order to show differen
You can do this with a switch statement using value binding and a where
clause. But convert the string to lowercase first!
var desc = "Going to be clear and bright tomorrow"
switch desc.lowercaseString as NSString {
case let x where x.rangeOfString("clear").length != 0:
println("clear")
case let x where x.rangeOfString("cloudy").length != 0:
println("cloudy")
default:
println("no match")
}
// prints "clear"