Objective c 自定义tableviewcell错误

Objective c 自定义tableviewcell错误,objective-c,uitableview,Objective C,Uitableview,我想使用自定义的tableview单元格 我有productTableViewCell类。在我的xib中,我定义了一个lblProduct,在这个标签上我想显示我的产品名称。我已经合成了它,并在我的xib中正确地连接了它 现在在我的另一节课上,我的tableview在里面。我这样做。我所有的产品都在arrayProducts中 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSInde

我想使用自定义的tableview单元格

我有productTableViewCell类。在我的xib中,我定义了一个lblProduct,在这个标签上我想显示我的产品名称。我已经合成了它,并在我的xib中正确地连接了它

现在在我的另一节课上,我的tableview在里面。我这样做。我所有的产品都在arrayProducts中

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    productTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {

        NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"productTableviewCell" owner:nil options:nil];

        for (UIView *view in views) {
            if([view isKindOfClass:[UITableViewCell class]])
            {   
                cell = (productTableviewCell*)view;
            }
        }
    }
    NSString *cellValue = [arrayProducts objectAtIndex:indexPath.row];
    NSLog(@"value: %@", cellValue);
    cell.lblProduct.text = cellValue;

    //  NSDictionary *info = [json objectAtIndex:indexPath.row];
    //cell.lblProduct.text = [info objectForKey:@"Pro_naam"];

    return cell;

}
但当我运行它时。我得到这个错误

2012-01-30 10:02:40.032 MamzelBestelling2[12923:f803]*终止 应用程序由于未捕获异常“NSUnknownKeyException”,原因: “[setValue:forUndefinedKey:]:此类不是 符合密钥LBL产品的密钥值编码。' *第一次抛出调用堆栈:(0x13c0052 0x1551d0a 0x13bff11 0x9b7032 0x928f7b 0x928eeb 0x943d60 0x23691a 0x13c1e1a 0x132b821 0x23546e 0x237010 0x4d9f 0xb0e0f 0xb1589 0x9cdfd 0xab851 0x56301 0x13c1e72 0x1d6a92d 0x1d74827 0x1cfafa7 0x1cfcea6 0x1cfc580 0x13949ce 0x132b670 0x12f74f6 0x12f6db4 0x12f6ccb 0x12a9879 0x12a993e 0x17a9b 0x2148 0x20a5)终止调用抛出异常当前语言:auto; 当前目标-c(gdb)


有人可以帮忙吗?

您实际上不需要先将其存储到NSString中。试着这样做:

cell.lblProduct.text = [arrayProducts objectAtIndex:indexPath.row];

还要确保您已经正确地完成了
@属性
@合成
,并将它们连接到CustomCell xib中

如果您创建了CustomTableViewCell,则必须为“lblProduct”设置一个标记,例如100。然后 做

它会起作用的


有关详细信息,我发现了问题。我的自定义tableview单元格中的标识符错误:)
UILabel *label=(UILabel *)[cell viewWithTag:100];
NSString *cellValue = [arrayProducts objectAtIndex:indexPath.row];
NSLog(@"value: %@", cellValue);
lblProduct.text = cellValue;

return cell;