Chapter 19
Adding a Search Bar Using Searchable

I knew that if I failed I wouldn't regret that, but I knew the one thing I might regret is not trying.

– Jeff Bezos

For most of the list-based apps, it is common to have a search bar at the top of the screen. How can you implement a search bar for data searching? In this chapter, we will add a search bar to the FoodPin app. With the search bar, we will enhance the app to let users search through the available restaurants.

Prior to iOS 15, SwiftUI didn't come with a built-in modifier for handling search in List views. Developers have to create your own solution. In our Mastering SwiftUI book, we have written a chapter showing you how to create a custom search bar in SwiftUI using TextField and display the search result.

With the release of iOS 15, the SwiftUI framework brings a new modifier named searchable to List views. You can simply attach the modifier to a list view and create a search field.

To access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.

results matching ""

    No results matching ""