I am working with a string of ingredients (salt, water, flour, sugar) for example, and want to search this string to see if specific items are on the list (salt, flour)
This is the code so far
let ingredientList = (JSONDictionary as NSDictionary)["nf_ingredient_statement"] as! String
if ingredientList.lowercaseString.rangeOfString("salt") != nil {
print("Salt Found!")
}
What would be the best way to implement a search for multiple substrings without repeating if statements?
The actual project will search for a dozen substrings, and 12 if statements is a pretty awkward solution.