Showing posts with label UITableViewDataSource tableView numberOfRowsInSection example. Show all posts
Showing posts with label UITableViewDataSource tableView numberOfRowsInSection example. Show all posts

Saturday, June 8, 2013

UITableViewDataSource tableView numberOfRowsInSection example in Objective C (iOS).


UITableViewDataSource tableView numberOfRowsInSection

Tells the data source to return the number of rows in a given section of a table view. (required)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

Parameters
tableView
The table-view object requesting this information.
section
An index number identifying a section in tableView.

Return Value of [UITableViewDataSource tableView numberOfRowsInSection]
The number of rows in section.

UITableViewDataSource tableView numberOfRowsInSection example.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (courses) {
    NSLog(@"Count: %i", [courses count]);
    return [courses count];
}
else {
    NSLog(@"Count: 0");
    return 0;
}
}

Example of [UITableViewDataSource tableView numberOfRowsInSection].
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"COUNTER: %i",[content count]);
    return [content count];
}

UITableViewDataSource tableView numberOfRowsInSection example.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return data.count;
}

End of UITableViewDataSource tableView numberOfRowsInSection example article.