PDA

View Full Version : UITableView populating at cell




LARRYSE
Sep 12, 2012, 10:36 PM
i have created an app that fills a tableview with a property from an customer object. this object contains 3 properties, item1, item2, and item3. if item1 equals the title name i want to show item2 in my cell. this is partially working as it formats the cell to the correct height and shows alternating colours but the text does not show.
if i just show all item2's the text appears.
here is my code

if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}


//Add a detail view accessory
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

//Step 3: Set text
CatQA *catQA = [questionAnswersList objectAtIndex:indexPath.row];

// NSLog(@"%@",catQA.question);

if(catQA.cat == self.title)
{
cell.textLabel.text = catQA.question;
}


cell.textLabel.font = [UIFont systemFontOfSize:17];
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;

//Step 4: return index row
return cell;

if i remove the if it will show all item2's text, but with if just correct sizing of cell but no text.
any suggestions? thanks



dejo
Sep 12, 2012, 11:28 PM
== is not the proper way to check equality of an NSString. There's an instance method you'll want to use.