Array displaying repeated object in table view cell

Prasad G

Use viewWithTag method and i have used it following method. Try like this. I think it will be helpful to you.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *CellIdentifier = @"myCell";
    UILabel* nameLabel = nil;
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil)
    {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

    }
    else
    {
        UILabel *titleLbl = (UILabel *)[cell viewWithTag:1];
        [titleLbl removeFromSuperview];
    }
    nameLabel = [[UILabel alloc] initWithFrame:CGRectMake( 7.0, 10.0, 160.0, 44.0 )];
    nameLabel.text = [labels objectAtIndex:indexPath.row];

    nameLabel.lineBreakMode = UILineBreakModeWordWrap;
    nameLabel.tag =1;
    nameLabel.numberOfLines =0;
    [nameLabel sizeToFit];
    CGSize expectedlabelsize = [nameLabel.text sizeWithFont:nameLabel.font constrainedToSize:nameLabel.frame.size lineBreakMode:UILineBreakModeWordWrap];
    CGRect newFrame =nameLabel.frame;
    newFrame.size.height =expectedlabelsize.height;
    [cell.contentView addSubview: nameLabel];
    return cell;
}