Leo Zhang
Leo Zhang

Reputation: 3230

How to get the section number of a specific UITableViewCell?

How to get the original indexPath.section by the specific UITableViewCell?

- (NSString *)sectionForCell:(UITableViewCell *)cell {
   //How to get the original indexPath.section by the specific UITableViewCell?
}

Upvotes: 2

Views: 6009

Answers (2)

Darren
Darren

Reputation: 10129

Use the UITableView instance method:

- (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell

Upvotes: 2

jrturton
jrturton

Reputation: 119242

UITableView has a method which gives you the index path of a particular cell:

NSIndexPath *path = [self.tableView indexPathForCell:cell];
return path.section;

Note that this would return an integer, not a string.

Upvotes: 6

Related Questions