Coding iPhone Apps for Kids: A Playful Introduction to Swift by Winquist Gloria & McCarthy Matt


Coding iPhone Apps for Kids: A Playful Introduction to Swift by Winquist Gloria & McCarthy Matt

Author:Winquist, Gloria & McCarthy, Matt [Winquist, Gloria]
Language: eng
Format: azw3
ISBN: 9781593277567
Publisher: No Starch Press
Published: 2017-05-11T04:00:00+00:00


Figure 11-5: The Settings app uses sections to group rows of different device settings.

The table view data source methods are called by the table view controller every time the table view is reloaded. Xcode automatically gives you these method templates when you make a subclass of a UITableViewController. You need to implement all three methods for the app to work, even though you’ll never call them directly in your code. The UITableViewController class implements the UITableViewDataSource protocol, which comes with these data source methods, to determine what will be displayed inside the table view. We’ll discuss protocols in “Delegation” on page 166. For now, you just need to know that a UITableViewController uses these methods to display its content, and it automatically calls these methods so you don’t need to call them.

Let’s start with the method numberOfSections(in:). The Birthdays table view controller is a list that just displays Birthday instances, so it doesn’t need multiple sections. To set the number of sections in the table view, we just need to return 1.

BirthdaysTableViewController.swift

override func numberOfSections(in tableView: UITableView) -> Int {

return 1

}



Loading...
Download




Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.