Working with UITableViewDataSource protocol in iOS Part2 @techytube
Working with UITableViewDataSource protocol in iOS Part2  @techytube
Uploaded November 2012 | Updated September 2026, 2 weeks ago
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
techytube.com/author/pavel

The UITableViewDataSource protocol is usually implemented by an ViewController class that mediates the application'™s data model for a UITableView object. The data source provides the table view object with the information it needs to construct and modify a table view.

As a representative of the data model, the data source supplies minimal information about the table view's appearance. The table-view object's delegate—an object adopting the UITableViewDelegate protocol—provides that information.

In the last video we've discussed about the required methods of the UITableViewDelegate protocol. There are also a couple of optional methods. For example in case of Grouped-Style table-views, we have sections, and each section may have a header and a footer.

To specify how many sections a table view should have, we implement the following method:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2; // 2 should be replaced with the number of sections we need
}

To specify the title of each section in a table view, we implement the following method:

- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
NSString *titleOfSection;

switch (section) {
case 0:
titleOfSection = @"First Section";
break;

case 1:
titleOfSection = @"Second Section";

// ... and so on, depending how many sections we must have

default:
titleOfSection = @"No Title";
break;
}

return titleOfSection;
}

For more, please visit Apple's online documentation at:

developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html
Working with UITableViewDataSource protocol in iOS Part2SonicWall - Administration, Time and Schedule configurationWorking with UITableViewDataSource protocol in iOS Part1Switch and Iterative statements in Objective CUnderstanding database backups in MS SQL Server 2008 R2Distributed File System Client Network Traffic Analysis with WiresharkWindows 8 Development - Javascript JSON ArraysRPM (Redhat Package Manager) Part 1 of 3User And Group Administration On Linux Part 2 of 4Windows 8 Development - App Bar IMS SQL Server Profiler Basics - 3Windows 8 Development - Windows Javascript Controls
techytube |

Working with UITableViewDataSource protocol in iOS Part2

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER