I am trying this code and getting below warning
Incompatible pointer types assigning to 'GuideTableViewCell' from 'UITableViewCell'
in line
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BusinessTableViewCell"];
Full Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
BusinessTableViewCell * cell = [self.tableView dequeueReusableCellWithIdentifier:@"BusinessTableViewCell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BusinessTableViewCell"];
}
BusinessInfo * business = self.businesses[indexPath.row];
cell.business = business;
return cell;
}
Also tried
BusinessTableViewCell *cell = [[UITableViewCell alloc]initWithStyle: UITableViewCellStyleDefault reuseIdentifier:@"BusinessTableViewCell"];
still getting the error can any one kindly give me some help.
thanks
You have two issues in your code. It should be:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
BusinessTableViewCell * cell = (BusinessTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:@"BusinessTableViewCell"];
if(!cell)
{
cell = [[BusinessTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BusinessTableViewCell"];
}
BusinessInfo * business = self.businesses[indexPath.row];
cell.business = business;
return cell;
}
dequeueReusableCellWithIdentifier
to the proper class. You get an error because your code cannot possibly work.
Your code expects a BusinessTableViewCell. You create a UITableViewCell. You should be creating a BusinessTableViewCell.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.