Avatar ·

How to check if a string contains another string in Swift?

Hi everyone! I'm new to Swift and writing my first app — a simple contact search. I have an array of strings with names, and I want to filter it based on the text entered by the user in UISearchBar. The problem is that I can't figure out how to properly check if a string contains a substring. In the documentation I found the `contains()` method, but it seems to work only for arrays, not for strings. Or am I mistaken? Here's what I'm trying: ```swift let searchText = "john" let name = "Johnny Appleseed" // Trying to check if name contains the substring searchText if name.contains(searchText) { print("Found!") } ``` But Xcode gives an error: `Value of type 'String' has no member 'contains'`. Although in other languages (like Python or JavaScript) I used `in` or