开发者

NSMutableDictonary of NSString getting null value

开发者 https://www.devze.com 2023-02-02 16:49 出处:网络
I\'m creating a NSMutableDictonary: dict = [[NSMutableDictionary alloc] init]; And after adding string items:

I'm creating a NSMutableDictonary:

dict = [[NSMutableDictionary alloc] init];

And after adding string items:

[dict setObject:@"three" forKey:@"apple"];
[dict setObject:@"factory" forKey:@"car"]开发者_StackOverflow社区;
[dict setObject:@"big bang" forKey:@"earth"];

I got the values if I try to access right after this. But if I try to access sometime after I got null value.

I belive it's because these strings is autoreleased. Then, the question is: What is the correct way to do this?


Really sorry guys! The example that I put here works, fine! The problem was the newbie debugging the code, me, making mistake about where is the problem. I was putting null value, believing that wasn't.

Thanks all.

0

精彩评论

暂无评论...
验证码 换一张
取 消