我在 cellForRowAtIndexPath 中使用以下代码,当我在 UILabel 中填充数据时,它正在发送错误
NSDictionary *benchmarkDictionary = (NSDictionary *)[benchmarkArray objectAtIndex:indexPath.row];
((UILabel *)[cell viewWithTag:15]).text = [benchmarkDictionary objectForKey:@"benchmarkTitle"];
((UILabel *)[cell viewWithTag:16]).text = [benchmarkDictionary objectForKey:@"benchmarkDescription"];
例外是:-[Benchmark objectForKey:]: unrecognized selector sent to instance 0x75d59c0 2013-03-08 16:21:39.515 Fdtrainer[2719:11303] *由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[Benchmark objectForKey :]: 无法识别的选择器发送到实例 0x75d59c0'
我的基准课程是:
@interface Benchmark : NSObject
@property (nonatomic, retain) NSString *bid;
@property (nonatomic, retain) NSString *benchmarkTitle;
@property (nonatomic, retain) NSString *benchmarkDescription;
-(id)initWithCoder: (NSCoder *)coder;
-(void)encodeWithCoder:(NSCoder *)encoder;
@end
@implementation Benchmark
@synthesize bid;
@synthesize benchmarkTitle;
@synthesize benchmarkDescription;
- (id) initWithCoder:(NSCoder *)coder {
self = [super init];
if(self) {
bid = [coder decodeObjectForKey:@"id"];
benchmarkTitle = [coder decodeObjectForKey:@"benchmarkTitle"];
benchmarkDescription = [coder decodeObjectForKey:@"benchmarkDescription"];
}
return self;
}
- (void) encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:bid forKey:@"id"];
[encoder encodeObject:benchmarkTitle forKey:@"benchmarkTitle"];
[encoder encodeObject:benchmarkDescription forKey:@"benchmarkDescription"];
}
@end