How to set heading text for a section of a group table

I want to set a caption text for each section of my grouped UITableView.

I tried this code, but getting the error "EXC_BAD_ACCESS"

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (tableView.tag==2) { if (section == 0) { return @"test1"; } if (section == 1) { return @"test2"; } } } 
+6
source share
1 answer

got his job, he had to add return @""; at the end for security.

 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (tableView.tag==2) { if (section == 0) { return @"test1"; } if (section == 1) { return @"test2"; } } return @""; } 
+23
source

Source: https://habr.com/ru/post/886455/


All Articles