我知道这个错误的含义,但我真的很苦恼,需要有人帮助我:
2010-09-21 15:03:11.562 Stocks[5605:207] *** Terminating app due to uncaught
exception 'NSUnknownKeyException', reason: '[<NSObject 0x499fb20>
setValue:forUndefinedKey:]: this class is not key value coding-compliant
for the key actionText.'
以下是我的代码:
AlertCell.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface AlertCell : UITableViewCell {
IBOutlet UILabel *actionText;
}
@property (retain, nonatomic) UILabel *actionText;
@end
并且
AlertCell.m
@implementation AlertCell
@synthesize actionText;
- (void)dealloc {
[actionText release];
[super dealloc];
}
@end
问题就发生在这里:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
AlertCell *cell =
(AlertCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"AlertCell"
owner:nil
options:nil];
for (id oneObject in nib) {
if ([oneObject isKindOfClass:[UITableViewCell class]]) {
cell = (AlertCell *)oneObject;
break;
}
}
}
cell.actionText.text = [arrayAlert objectAtIndex:indexPath.row];
return cell;
}
在这一行:
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"AlertCell"
owner:nil
options:nil];
正如被问到的那样,这是我的TableViewCOntroller的标题:
#import <UIKit/UIKit.h>
@interface AlertesViewController : UITableViewController {
NSMutableArray *arrayAlert;
}
你可以查看我的XIB文件(以XML格式):http://pastebin.com/FDVzLYZu
@end
有人能帮我吗?非常感谢!
UITableViewController
的头文件吗?我怀疑你将错误的对象设置为AlertCell
的“File's Owner”。 - falconcreek