好吧,这快把我逼疯了--请告诉我,我没有失去理智!
我宣布:
NSMutableDictionary* generalSettingsDict;我是我的.h
我猜:
generalSettingsDict = [[NSMutableDictionary alloc] initWithCapacity:5];在viewWillAppear中
我设定:
[generalSettingsDict setValue:[NSNumber numberWithBool:control.on]
forkey:[NSNumber numberWithInt:control.tag]];以一种方法:
-(void)settingChanged:(UISwitch*)control forEvent:(UIEvent *)event我得到了,“NSMutableDictionary可能不会响应setValue:forkey:"和应用程序在运行时崩溃。
请帮助:(
发布于 2009-07-28 18:09:31
( A) forkey:应该是forKey:。资本化很重要。
( B) setValue:forKey:是一种KVC方法。它可能如您在这里所期望的那样工作,但用于NSMutableDictionary的适当方法是setObject:forKey:。
发布于 2009-07-28 18:09:14
你想要setObject:forKey:。setValue:forKey:是键值编码协议的一部分.NSMutableDictionary提供setObject:forKey:。
https://stackoverflow.com/questions/1195744
复制相似问题