This is what I came up with and it works well:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSManagedObject *managedObject = [newClass objectAtIndex:indexPath.row];
NSString *entityName= [[managedObject entity]name];
NSDate *date = [managedObject valueForKey:@"lastmoddate"];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"EEE h:mm a MMM d, yy'''"];
NSString *dateString = [formatter stringFromDate:date];
UILabel *lblUser = [[UILabel alloc] initWithFrame:CGRectMake(30, 8, 215, 14)];
lblUser.text = [NSString stringWithFormat:@"%@ %i", entityName, [indexPath row]];
lblUser.textColor = [UIColor blackColor];
lblUser.font = [UIFont systemFontOfSize:16.0];
lblUser.tag = 1;
[lblUser setBackgroundColor:[UIColor clearColor]];
UILabel *lblDate = [[UILabel alloc] initWithFrame:CGRectMake(30, 21, 215, 20)];
lblDate.text = dateString;
lblDate.textColor = [UIColor grayColor];
lblDate.font = [UIFont systemFontOfSize:12.0];
lblDate.tag = 2;
[lblDate setBackgroundColor:[UIColor clearColor]];
if ((([cell.contentView viewWithTag:1]) && ([cell.contentView viewWithTag:2])))
{
[[cell.contentView viewWithTag:1]removeFromSuperview];
[[cell.contentView viewWithTag:2]removeFromSuperview];
}
[cell.contentView addSubview:lblDate];
[cell.contentView addSubview:lblUser];
return cell;
}