我使用以下代碼的異常,當我在的UILabel填充數據被髮送錯誤的UITableViewCell生成對的cellForRowAtIndexPath對細胞項目設定文本
NSDictionary *benchmarkDictionary = (NSDictionary *)[benchmarkArray objectAtIndex:indexPath.row];
((UILabel *)[cell viewWithTag:15]).text = [benchmarkDictionary objectForKey:@"benchmarkTitle"];
((UILabel *)[cell viewWithTag:16]).text = [benchmarkDictionary objectForKey:@"benchmarkDescription"];
例外是: - [基準objectForKey:]:無法識別選擇發送到實例0x75d59c0 2013年3月8日16:21:39.515 Fdtrainer [2719:11303] *終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因:「 - [基準objectForKey:]:無法識別的選擇發送到實例0x75d59c0'
我的Benchmark類是:
@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
仍給它同樣的錯誤 – 2013-03-08 14:06:22