-(id)init{
if (self==[super init]) {
NSMutableArray *listname = [[NSMutableArray alloc]initWithObjects:@"cu",@"al",@"zn",@"au",@"ru",@"fu",@"rb",@"pb",@"wr", nil];
NSMutableArray *listVolumn = [NSMutableArray arrayWithCapacity:[listname count]];
for (int i=0; i<[listname count]; i++) {
[listVolumn addObject:[NSNumber numberWithLong:0]];
}
nsmutabledictionary = [[NSDictionary alloc] initWithObjects:listVolumn forKeys:listname];
}
return self;
}
在我的init方法中,我定義了兩個NSMutableArray,並將其添加到NSMutableDictionary nsmutabledictionary中。在我的另一種方法 :[__NSCFDictionary setObject:forKey:]:發送到不可變對象的變異方法
[nsmutabledictionary setObject:[NSNumber numberWithLong:100] forKey:@"cu"];
但它墜毀在上述行:
謝謝你,你是對的 – Gaojian922188