0

Could you please help me populate my left detail cell?

what i need is to use the Attribute key from my core Data as the left detail and the content of the Attribute as the Title.

I have fetched an object into an array and I need help displaying the data on the cell

 if (matchingData.count <= 0)
{
    cell.textLabel.text = @"no item found";
}
else {
    NSString *displayData;
    for (NSManagedObject *obj in matchingData) {
        displayData = [obj valueForKey:@"Name"];
        cell.detailTextLabel.text = displayData;
        cell.textLabel.text = @"Name";

      }
   }

what do I need to do in order to get the Table view displaying just like the apple contacts app?

Ray
  • 31
  • 4
  • Did u init ur tableview cell's style as UITableViewCellStyleSubtitle? Check this http://stackoverflow.com/questions/2349279/cell-detailtextlabel-text-not-working-why – HRM Feb 28 '13 at 15:33

1 Answers1

0

To be able to use the detailTextLabel you need to initialize your cell with type UITableViewCellStyleSubtitle like this:

static NSString *MyCellIdentifier = @"AUniqueIdentifier";

    UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:MyCellIdentifier];

    if (!cell) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MKCellIdentifier];
    }

I would also check that displayData is not nil or an empty screen, like this if (displayData.length > 0)

Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118