Graphics Programs Reference
In-Depth Information
UITableViewController
UITableView is a view object, so, according to Model-View-Controller, it knows how to
draw itself, but that's it. It doesn't handle application logic or data. Thus, when using a
UITableView , you must consider what else is necessary to get the table working in your
application
• A UITableView typically needs a view controller to handle its appearance on
the screen.
• A UITableView needs a data source . A UITableView asks its data source for
the number of rows to display, the data to be shown in those rows, and other tidbits
that make a UITableView a useful user interface. Without a data source, a table
view is just an empty container. The dataSource for a UITableView can be
any type of Objective-C object as long as it conforms to the UIT-
ableViewDataSource protocol.
• A UITableView typically needs a delegate that can inform other objects of
events involving the UITableView . The delegate can be any object as long as
(you guessed it!) it conforms to the UITableViewDelegate protocol.
An instance of the class UITableViewController can fill all three roles: view con-
troller, data source, and delegate.
UITableViewController is a subclass of UIViewController , so a UIT-
ableViewController has a view . A UITableViewController 's view is al-
ways an instance of UITableView , and the UITableViewController handles the
preparation and presentation of the UITableView . When a UITableViewControl-
ler creates its view, the dataSource and delegate instance variables of the UIT-
ableView are automatically set to point at the UITableViewController ( Fig-
ure 9.4 ).
Figure 9.4 UITableViewController-UITableView relationship
 
Search WWH ::




Custom Search