对成员变量的请求不是结构

时间:2011-09-25 17:11:20

标签: iphone objective-c cocoa-touch

好的,所以我在IB中创建了一个自定义的uitablviewcell,我创建的类名为CustomCell 我已经在头文件中导入了它,这里有一些代码

 // Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"CustomCell";

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

    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];

    for (id currentObject in topLevelObjects){
        if ([currentObject isKindOfClass:[UITableViewCell class]]){
            cell =  (CustomCell *) currentObject;
            break;
        }
    }
}

//errors start
cell.usernameText.text = [usernameArray objectAtIndex:[indexPath row]];
cell.regionText.text = [regionArray objectAtIndex:[indexPath row]];
cell.gamesText.text = [gamesArray objectAtIndex:[indexPath row]];
cell.infoText.text = [aboutArray objectAtIndex:[indexPath row]];
cell.concoleText.text = [concoleArray objectAtIndex:[indexPath row]];
cell.micText.text = [NSString stringWithFormat:@"Mic:%@",[MicArray objectAtIndex:[indexPath row]]];

cell.ageText.text = [ageArray objectAtIndex:[indexPath row]];   
  //till her
return cell;
}

为什么会出现错误,我该怎么做才能解决问题。

1 个答案:

答案 0 :(得分:1)

  

你有自己的CustomCell类(UITableViewCell)吗?    并拥有CustomCell的成员usernameText,regionText,gamesText,infoText,concoleText,micText和ageText?如果否,那么您将收到警告成员变量请求不是结构,因为它们不是成员变量。如果你没有为它创建单独的类文件,那么你可以调用cell。textLabel。text = @“Welcome”textLabel是UITableViewCell的成员。

并且您没有告诉您使用了什么错误