Incompatible pointer types warning (in Objective-C)

compiler-warnings, objective-c, types, variable-assignment

Solution

Assuming that cellForRowAtIndexPath is properly coded, and is known to always return a `SiteCell`, you simply need to cast to `SiteCell*`:

SiteCell *cell = (SiteCell*)[tableView cellForRowAtIndexPath:indexPath];

Problem

I'm still a bit green in iOS development and keep getting a warning that I'm not sure about. I am using a custom cell in a tableview and have set its class to be a subclass of UITableViewCell called SiteCell. In my "didSelectRowAtIndexPath" method when I declare the selected cell as a SiteCell type, I receive the following warning: Incompatible pointer types initializing SiteCell __strong with an expression of type UITableViewCell ``` -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ SiteCell *cell = [tableView cellForRowAtIndexPath:indexPath]; NSString *rowIdentity = [NSString stringWithFormat:@"%d", indexPath.row]; [selectedRows setObject:[cell.siteTitleLabel text] forKey:rowIdentity]; if(cell.accessoryType == UITableViewCellAccessoryCheckmark){ cell.accessoryType = UITableViewCellAccessoryNone; }else{ cell.accessoryType = UITableViewCellAccessoryCheckmark; } } ``` Can anyone shed any light on how to get rid of this warning?

Original source