我得到了这个错误:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x5a37750> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key destination.'代码如下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ReservationCell";
ReservationCell *cell = (ReservationCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ReservationCell" owner:nil options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (ReservationCell *) currentObject;
break;
}
}
}
//cell.origin.text = [[data objectAtIndex:indexPath.row] origin];
//cell.destination.text = [[data objectAtIndex:indexPath.row] destination];
//cell.time_range.text = [[data objectAtIndex:indexPath.row] time_range];
return cell;
}这里是ReservationCell.h
@interface ReservationCell : UITableViewCell {
UILabel * origin;
UILabel * destination;
UILabel * time_range;
}
@property (nonatomic, retain) IBOutlet UILabel * origin;
@property (nonatomic, retain) IBOutlet UILabel * destination;
@property (nonatomic, retain) IBOutlet UILabel * time_range;
@end下面是我如何把它连接起来的:

发布于 2012-05-14 19:07:44
对于像我这样已经接触到这个主题但不能找到解决方案的人,这里是这个问题的快速解决方案:
在界面构建器中,当您应该从单元格视图中链接IBOutlets时,您却链接了来自文件所有者的文件。这就是你得到这些错误的原因。
祝你好运!
https://stackoverflow.com/questions/5343172
复制相似问题