Skip to content

Commit

Permalink
Refactors -[tableView:cellForRowAtIndexPath:] (#3326)
Browse files Browse the repository at this point in the history
Fixes static analyzer issue complaining  -[tableView:cellForRowAtIndexPath:] returns nil.
  • Loading branch information
valeriyvan authored and jjatie committed Mar 11, 2018
1 parent 0ceab4e commit 695979e
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions ChartsDemo/Objective-C/DemoBaseViewController.m
Expand Up @@ -170,7 +170,8 @@ - (IBAction)optionsButtonTapped:(id)sender
_optionsTableView.backgroundColor = [UIColor colorWithWhite:0.f alpha:0.9f];
_optionsTableView.delegate = self;
_optionsTableView.dataSource = self;

[_optionsTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];

_optionsTableView.translatesAutoresizingMaskIntoConstraints = NO;

NSMutableArray *constraints = [[NSMutableArray alloc] init];
Expand Down Expand Up @@ -224,23 +225,14 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == _optionsTableView)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cell.backgroundView = nil;
cell.backgroundColor = UIColor.clearColor;
cell.textLabel.textColor = UIColor.whiteColor;
}

cell.textLabel.text = self.options[indexPath.row][@"label"];

return cell;
}

return nil;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.backgroundView = nil;
cell.backgroundColor = UIColor.clearColor;
cell.textLabel.textColor = UIColor.whiteColor;

cell.textLabel.text = self.options[indexPath.row][@"label"];

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down

0 comments on commit 695979e

Please sign in to comment.