Chapter 10
Understanding List, ForEach and Identifiable

In UIKit, UITableView is one of the most common UI controls in iOS. If you have experience developing apps with UIKit, you are familiar with the use of table views for presenting lists of data. This UI control is commonly used in content-based apps such as newspaper apps. Figure 1 illustrates some examples of list/table views that can be found in popular apps like Instagram, Twitter, Airbnb, and Apple News.

Figure 1. Sample list views
Figure 1. Sample list views

Instead of using UITableView, we use List in SwiftUI to present rows of data. If you've built a table view with UIKit before, you are aware that it can take you significant effort to implement a simple table view and even more effort to customize the layout of the cells. SwiftUI simplifies this entire process. With just a few lines of code, you can easily list data in table form. Even if you need to customize the layout of the rows, it only requires minimal effort.

Feeling confused? No worries. You'll understand what I mean in a while.

In this chapter, we will start with a simple list. Once you grasp the basics, I will show you how to present a list of data with a more complex layout, as shown in Figure 2.

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 ""