我尝试在NSDictionary
中插入NSMutableDictionary
。没有错误但它不起作用,它仍然是空的。
这是我的代码:
NSMutableDictionary *einnahmen = [[NSMutableDictionary alloc] initWithCapacity:20];
NSArray *objects = [NSArray arrayWithObjects:
name,
[NSNumber numberWithInt: x],
[NSNumber numberWithInt: y],
[NSNumber numberWithInt: z],
nil];
NSArray *keys = [NSArray arrayWithObjects:
@"name",
@"startJahr",
@"zins",
@"entnahmefaehig",
nil];
NSDictionary *entry = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[einnahmen setObject:entry forKey:@"name"]; //seems not to work
调试器显示[einnahmen setObject:entry
之后:
答案 0 :(得分:2)
我已经解决了这个问题。以下代码使用了错误的init-method:
NSMutableDictionary *einnahmen =
[[NSMutableDictionary alloc] initWithCapacity:20];
编译器应显示错误。