CS 185C/286 - Lecture 13

Cay S. Horstmann
Lecture 13 Quiz 1
When you write a file in Objective C, how do you get notified if there is an error?
- The
writeToFile method returns YES if it succeeded, NO if it failed.
- The
writeToFile method returns an integer error code.
- You pass a pointer to an
NSError object that is filled with an error descriptor if an error occurred.
- An exception is thrown that you should catch.
Lecture 13 Quiz 2
What is true about Objective-C protocols?
- They are like generics in Java. For example,
@protocol Fred <P1, P2> means that Fred has type parameters P1 and P2.
- They are like multiple inheritance in C++. For example,
@protocol Fred <P1, P2> means that Fred inherits from P1 and P2.
- They are like interfaces in Java. For example,
@protocol Fred <P1, P2> means that Fred implements P1 and P2.
- None of the above
Today's Lecture/Lab
- Exam review
- Project status presentations
- iOS tables
Table Views
- Tables are everywhere

Table Views
- Table view instance of
UITableView
- Each row is instance of
UITableViewCell

- Table gets data from object conforming to
UITableViewDelegate protocol
- Row data from object conforming to
UITableViewDataSource protocol
- Row data is cached but needs to be re-supplied on demand
Table Styles
- Grouped, plain, indexed

- Each division is a section
Reading Before Next Class

- Read chapter 8 (Introduction to Table Views) in Beginning iOS 5 Development
Lab

- Bring your laptop to the lab
- You will work with a buddy
- For this lab, match yourself up with a buddy who has a Mac
- I want you to submit your lab code to git. But don't use the git support in the IDE.
- Instead, tell XCode to put your (unmanaged) project into the
workspace/lab13 directory.
Simple Tables
- Follow the iPhone programming book Chapter 8, Implementing a Simple Table
- Add a table view as described.
- Wire the controller as described. Which methods belong to the
UITableViewDelegate protocol and which to UITableViewDataSource?
- Go on to the section "Adding an image". Just use this image.
- Now use this image for the Disney dwarves (up to Dopey), and the other image for the Tolkien dwarves. How do you do that?