UITableView populating at cell

Discussion in 'iOS Programming' started by LARRYSE, Sep 12, 2012.

  1. LARRYSE macrumors newbie

    Aug 22, 2012
    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
  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    == is not the proper way to check equality of an NSString. There's an instance method you'll want to use.

Share This Page