Lesson 4 Code Reference Sheet

This outline is intended as a quick way to reference code snippets from this lesson. It includes any code you were expected to write yourself and git branch names for code provided for you.

FavoriteThings Quiz

Here is a working implementation of numberOfRowsInSection for Favorite Things:

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return self.favoriteThings.count

Implementing cellForRowAtIndexPath

This method performs the following steps in the Favorite Things App: dequeue a reusable cell from the table, using the correct “reuse identifier” Find the model object that corresponds to that row Set the images and labels in the cell with the data from the model object return the cell.

Here’s the code:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {    
    let cell = tableView.dequeueReusableCellWithIdentifier
    ("FavoriteThingCell") as! UITableViewCell
    cell.textLabel.text = self.favoriteThings[indexPath.row]
    return cell

See this method in context by checking out step4.3-favoriteThings-complete.

Do-Re-Mi App

To practice with the DoReMi app check out step4.4-doReMi-incomplete. To see a completed version see step4.4.1-doReMi-complete

Exploring the Bond Villains project

To explore the incomplete Bond Villains project see step4.5-bondVillains-incomplete.

Choosing Cell Styles

To see the completed Bond Villains project go to step4.6-bondVillains-complete

Challenge App: Roshambo with History

To begin the Challenge App checkout step4.7-roshamboWithHistory-incomplete

Steps to Build Roshambo with History

To see a solution to the Challenge App checkout step4.8-roshamboWithHistory-solution