class book{ var nameOfBook: String! } var englishBooks=[book(),book(),book()] var arr = englishBooks.filter { contains($0.nameOfBook, \"rt\") }
I think this is more useful for lack of wrong typing situation.
englishBooks.filter( { $0.nameOfBook.range(of: searchText, options: .caseInsensitive) != nil}