I’d like to return an NSMutableArray with three objects. Here’s what I’ve got:
NSMutableArray *output = [[NSMutableArray alloc] init];
NSString *a = [[NSString alloc] initWithFormat:@"%i",aa];
NSString *b = [[NSString alloc] initWithFormat:@"%i",bb];
NSString *c = [[NSString alloc] initWithFormat:@"%i",cc];
[output addObject:a];
[output addObject:b];
[output addObject:c];
return output;
But I’m getting memory leaks. What is wrong?
1st Issue:
Try it that way, then the NSString will get released.
[NSString stringWithFormat:@"%@", aa];keep also an eye on the format-placeholders:
2nd Issue:
and do an autorelease with your output var, because the last action in the function is the reset.
complete snippet:
cheers endo