gpt4 book ai didi

iphone - 类不符合键值编码

转载 作者:行者123 更新时间:2023-12-03 18:09:21 26 4
gpt4 key购买 nike

我知道这个错误的含义,但我真的很挣扎,我需要有人的帮助:

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 header :

#import <UIKit/UIKit.h>


@interface AlertesViewController : UITableViewController {
NSMutableArray *arrayAlert;
}

您可以看到我的 XIB 文件(XML 格式):http://pastebin.com/FDVzLYZu

@结束

有人可以帮助我吗?非常感谢!

最佳答案

您的代码可能基于网络教程,例如 http://www.e-string.com/content/custom-uitableviewcells-interface-builder 中的教程。或http://www.icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/

你的问题(我99%确定这就是你绊倒的地方,我刚刚犯了同样的错误)是,在界面生成器中,当你应该从单元格 View 链接它们时,你从文件所有者链接了IBOutlet。这就是您收到错误的原因。

关于iphone - 类不符合键值编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3760803/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com