NSMutableDictionary memory / address problem, release does not work?

Posted by phil on Stack Overflow See other posts from Stack Overflow or by phil
Published on 2010-06-10T03:34:48Z Indexed on 2010/06/10 3:42 UTC
Read the original article Hit count: 331

I am trying to create a NSMutableDictionary(dictA) with objectA. When I try to view my dictionary(NSLog), each key is pointing to the same address. I have an objectA_1 which is type objectA and used to setup the dictionary. Also, if I try to getObject, I always get the last key/value that was added to the dictionary. I tried setValue and got the same results. Is there something wrong with my objectA? Is the release method not working properly? Am I retaining when I shouldn't? Thank you.

dictA = [[NSMutableDictionary alloc] init];
objectA *objectA = [[objectA alloc] init];

[dictA setObject:objectA_1 forKey:@"apple"];
[objectA_1 release];
[dictA setObject:objectA_1 forKey:@"japan"];
[objectA_1 release];
[dictA setObject:objectA_1 forKey:@"paris"];
[objectA_1 release];
[dictA setObject:objectA_1 forKey:@"pizza"];
[objectA_1 release];

//NSlog: apple = ""; japan = ""; paris = ""; pizza = "";

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about memory-management