2011-10-13 11 views
6
-(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; 
} 

nel mio metodo init, ho definito due NSMutableArray, e ha aggiunto di NSMutableDictionary NSMutableDictionary. nel mio altro metodo:[__NSCFDictionary setObject: Forkey:]: metodo di mutazione inviati oggetto immutabile

[nsmutabledictionary setObject:[NSNumber numberWithLong:100] forKey:@"cu"]; 

ma incidente alla linea di cui sopra: enter image description here

risposta

16
nsmutabledictionary = [[NSDictionary alloc] initWithObjects:listVolumn forKeys:listname]; 

dovrebbe essere

nsmutabledictionary = [[NSMutableDictionary alloc] initWithObjects:listVolumn forKeys:listname]; 
+0

grazie, hai ragione – Gaojian922188

2

Nel codice vedo che nsmutabledictionary = [[NSDictionary alloc] initWithObjects:listVolumn forKeys:listname]; che linea dichiarata è NSDictionary mentre intendi che sia NSMutableDictionary

+0

grazie mille, hai ragione. – Gaojian922188

Problemi correlati