UITableView, how do I know what Section during cellForRowAtIndexPath?
The method is called
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
The indexpath parameter contains a row and section property.
indexPath.section indexPath.row
Here's documentation link for the NSIndexPath class.
Swift 3, 4 and 4.2
Using Switch
switch indexPath.section { case 0: print("Write your code for section number one.") case 1: print("Write you code for section number two") default: return }
Using if else
if indexPath.section == 0 { print("Write your code for section number one.") } else if indexPath.section == 1 { print("Write your code for section number two.") }