Here is a sample code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { OMAllAbonementTableViewCell *cellAbonement = [tableView dequeueReusableCellWithIdentifier:abonementIdentifier]; OMVIPAbonementTableViewCell *cellVIPAbonement = [tableView dequeueReusableCellWithIdentifier:vipabonementIdentifier]; if (!cellAbonement) { cellAbonement = [[OMAllAbonementTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:abonementIdentifier]; } OMAbonement *abonement = (OMAbonement *)self.allBenefit[indexPath.row]; cellAbonement.benefitAbonementImage.image = abonement.photo; cellAbonement.benefitAbonementLabel.text = [NSString stringWithFormat:@"%@ %@", abonement.name, abonement.surname]; if (!cellVIPAbonement) { cellVIPAbonement = [[OMVIPAbonementTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:vipabonementIdentifier]; } OMVIPAbonement *vipabonement = (OMVIPAbonement *)self.allBenefit[indexPath.row]; cellVIPAbonement.benefitVIPAbonementImage.image = vipabonement.photo; cellVIPAbonement.benefitVIPAbonementLabel.text = [NSString stringWithFormat:@"%@", vipabonement.name]; return cellVIPAbonement; return cellAbonement; 

}

  • you need to choose what identifier you need based on indexPath and work with it - Max Mikheyenko
  • It is possible in more detail, but something is not very good for me) - Orest Mykha
  • and what criterion for cells? on the basis of what should be one or the second? - Max Mikheyenko 5:53 pm
  • There is an array with elements of two classes. One cell should reflect the elements of one class and the other. Is it possible to do this ?. - Orest Mykha
  • Well, it is not difficult. how are the classes called? - Max Mikheyenko

1 answer 1

did not check, but it seems to work

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if([self.allBenefit[indexPath.row] isMemberOfClass:[OMAbonement class]]) { OMAllAbonementTableViewCell *cellAbonement = [tableView dequeueReusableCellWithIdentifier:abonementIdentifier]; if (!cellAbonement) { cellAbonement = [[OMAllAbonementTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:abonementIdentifier]; } OMAbonement *abonement = (OMAbonement *)self.allBenefit[indexPath.row]; cellAbonement.benefitAbonementImage.image = abonement.photo; cellAbonement.benefitAbonementLabel.text = [NSString stringWithFormat:@"%@ %@", abonement.name, abonement.surname]; return cellAbonement; } if([self.allBenefit[indexPath.row] isMemberOfClass:[OMVIPAbonement class]]) { OMVIPAbonementTableViewCell *cellVIPAbonement = [tableView dequeueReusableCellWithIdentifier:vipabonementIdentifier]; if (!cellVIPAbonement) { cellVIPAbonement = [[OMVIPAbonementTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:vipabonementIdentifier]; } OMVIPAbonement *vipabonement = (OMVIPAbonement *)self.allBenefit[indexPath.row]; cellVIPAbonement.benefitVIPAbonementImage.image = vipabonement.photo; cellVIPAbonement.benefitVIPAbonementLabel.text = [NSString stringWithFormat:@"%@", vipabonement.name]; return cellVIPAbonement; } return nil; } 
  • Thank you very much) Everything works))). Very cool solution) - Orest Mykha