You are building the dictionary incorrectly. Why not just do:
NSMutableDictionary *soundDict = [@{
@"Random" : @NO,
@"Cricket" : @NO,
@"Mosquito" : @NO,
@"Fly" : @NO,
@"Owl" : @NO,
@"Scratching" : @NO,
@"Whistle" : @NO
} mutableCopy];
Then your setSoundDictValue:forKey:
method becomes:
- (void)setSoundDictValue:(BOOL)value forKey:(NSString *)key {
sound[key] = @(value);
}
The problem with your code is easier to see if you split it up:
- (void)setSoundDictValue:(BOOL)value forKey:(NSString *)key {
NSArray *sounds = [soundDict objectForKey:@"Sound Values"];
[sounds setValue:[NSNumber numberWithBool:value] forKey:key];
}
As you can see, you try to call setValue:forKey:
on an NSArray
.