Chapter 14
Data Sharing with Combine and Environment Objects

In the previous chapter, you learned how to layout a form using the Form component. However, the form is not yet functional. Regardless of the options selected, the list view doesn't change to reflect the user's preferences. In this chapter, we will continue developing the settings screen and make the app fully functional by updating the restaurant list based on the user's preferences.

In the upcoming sections, we will cover the following topics:

  1. How to use enum to better organize our code
  2. How to store the user's preference permanently using UserDefaults
  3. How to share data using Combine and @Environment
Figure 4. The list view now refreshes its items when you change the filter preference
Figure 4. The list view now refreshes its items when you change the filter preference

To access the full content and the complete source code, please get your copy at https://www.appcoda.com/swiftui.

results matching ""

    No results matching ""