-(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;
}
Run Code Online (Sandbox Code Playgroud)
在我的init方法中,我定义了两个NSMutableArray,并添加到NSMutableDictionary nsmutabledictionary.在我的另一种方法:
[nsmutabledictionary setObject:[NSNumber numberWithLong:100] forKey:@"cu"];
Run Code Online (Sandbox Code Playgroud)
但它崩溃在上面的线:
Aks*_*hay 16
nsmutabledictionary = [[NSDictionary alloc] initWithObjects:listVolumn forKeys:listname];
Run Code Online (Sandbox Code Playgroud)
应该
nsmutabledictionary = [[NSMutableDictionary alloc] initWithObjects:listVolumn forKeys:listname];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13176 次 |
最近记录: |