Memory Management - Objective C NSString
Posted
by
reising1
on Stack Overflow
See other posts from Stack Overflow
or by reising1
Published on 2011-01-11T03:21:25Z
Indexed on
2011/01/11
4:54 UTC
Read the original article
Hit count: 312
I have an NSMutableDictionary called "output" and I am adding an NSString into it that is an integer. What is the proper way to do this? I can't figure it out. Everything I've tried ends up giving memory leaks.
This is what I currently have:
val is an int
countryName is an NSString
Here is how I declare "output":
NSMutableDictionary *output = [[[NSMutableDictionary alloc] init] autorelease];
Here is the code that causes a memory leak:
NSString *temp = [NSString stringWithFormat:@"%d",val];
[output setValue:temp forKey:countryName];
© Stack Overflow or respective owner