寻求帮助诊断以下错误:
* 由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[<__NSCFBoolean 0x39d40da8> setValue:forUndefinedKey:]:此类不符合键 Cricket 的键值编码。”
这是代码:
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];
…
}
谢谢托尼。