Memory Management - Objective C NSString
- by reising1
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];