Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView in iPhone app - how to get number of rows

How can i store the number of current rows in a uitable into a variable?

This is my code for the table (that i think might be relevant):

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];

}

like image 775
benhowdle89 Avatar asked Dec 07 '10 21:12

benhowdle89


People also ask

What is table view in iOS?

Overview. Table views in iOS display rows of vertically scrolling content in a single column. Each row in the table contains one piece of your app's content. For example, the Contacts app displays the name of each contact in a separate row, and the main page of the Settings app displays the available groups of settings ...

What is table view?

A screen display of several items or records in rows and columns.

What is numberofrowsinsection?

Returns the number of rows (table cells) in a specified section.


1 Answers

You should really get this from the source of the data, rather than the table view itself, I'd have thought. (It's a bit arse about face as they'd say around here.)

That said, you could use the numberOfRowsInSection: method within the UITableView as you've shown in your example.

like image 107
John Parker Avatar answered Oct 15 '22 13:10

John Parker