Skip to Main Content
Learning Swift, 3rd Edition
book

Learning Swift, 3rd Edition

by Jonathon Manning, Paris Buttfield-Addison, Tim Nugent
March 2018
Beginner content levelBeginner
378 pages
8h 45m
English
O'Reilly Media, Inc.
Content preview from Learning Swift, 3rd Edition

Chapter 6. Building the Selfie List UI

With a model object tested and working, it is time to start building up the UI for the app. To start with, we’ll make the UI for showing the list of previously taken selfies.

Creating the Selfie List

As we are using a Master-Detail template, the basic UI has been set up already in the storyboard; we just need to bash it into the shape that we need. The bulk of what we are going to be doing is using the UITableView and UITableViewController classes to make our selfie list.

The UITableView class is a specialized subclass of UIView designed to show lists of information. A table view is comprised of one or more sections, and each section has zero or more table view cells. A table view cell can be thought of as just a normal view—it can present anything you want it to.

The data for the table view cells and sections comes from the table view’s UITableViewDataSource property. Whenever a table view needs to present information, such as how many cells are there in a section or what a single cell should show, it asks its data source for the answer. This means a table view itself has no knowledge of what it is showing or how it is to be structured—that is all handled for it by the data source. A table view also has a delegate that gets told when non–data related events are occurring, such as when a row has been selected.

Index paths are an important part of table views that get used a great deal by both the data source and the delegate. An index path ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning To Program With Swift

Learning To Program With Swift

T. Rogers

Publisher Resources

ISBN: 9781491987568Errata Page