Chapter 15. Table views: more than a coffee table picture book

 

This chapter covers

  • Delegation and protocols
  • Data source
  • Table views
  • Tuples

Table views are powerful tools that allow you to present data to your users in a clean, organized way. You’ve seen table views on your iPhone and iPad many times, though you probably didn’t know they were called table views. Open your Phone app, and navigate to the Favorites screen if it isn’t open already. If you aren’t horribly lonely, you should have at least one or two people that you call frequently enough that you’ve added them to your Favorites. If you don’t have any favorites added, look at the Contacts screen to see a list of your contacts. Each of your favorites is a row in a table. Each of your contacts is a row in a different table. Who knew?

You’re going to learn all about table views in this chapter, but we need to cover some underlying concepts first, so bear with me. Don’t worry—this is fun stuff.

15.1. Delegation

Swift uses a concept known as delegation, and you’ve used it in the real world, I’m sure. Let’s say you want pizza for dinner. There are many options for pizza, including heating up a frozen pizza, ordering a pizza from a variety of different pizza places, or making a pizza from scratch. Let’s start by making a pizza from scratch.

15.1.1. Making pizza from scratch

15.2. Protocols

15.3. Data sources

15.4. Creating a table view app

15.5. Summary