【发布时间】:2013-07-12 00:49:03
【问题描述】:
寻求帮助诊断以下错误:
* 由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[<__nscfboolean> setValue:forUndefinedKey:]:此类不是键值编码-符合关键板球。'
代码如下:
NSMutableArray *soundNames = [[NSMutableArray alloc] initWithObjects:@"Random", @"Cricket", @"Mosquito", @"Fly", @"Owl", @"Scratching", @"Whistle", nil];
NSNumber *noObj = [NSNumber numberWithBool:NO];
NSMutableArray *soundValues = [[NSMutableArray alloc] initWithObjects:noObj, noObj, noObj, noObj, noObj, noObj, noObj, nil];
NSMutableDictionary *soundDict = [[NSMutableDictionary alloc]initWithObjectsAndKeys:soundNames, @"Sound Names", soundValues, @"Sound Values", nil]];
- (void)setSoundDictValue:(BOOL)value forKey:(NSString *)key
{
[[soundDict objectForKey:@"Sound Values"] setValue:[NSNumber numberWithBool:value] forKey:key];
…
}
谢谢 托尼。
【问题讨论】:
标签: ios nsmutablearray key-value-coding uncaught-exception