Reputation: 161
when i copy a NSMutableDictionary object into NSMutableArray object like:
[array addObject:[dictionary copy]];
then i got a memory leak:Method returns an objective-C object with a +1 retain count.
Upvotes: 0
Views: 52
Reputation: 2918
If you want to avoid autorelease, You can also try this:
NSMutableDictionary temp = [dictionary copy];
[array addObject:temp];
[temp release];
Upvotes: 1
Reputation: 32066
Both addObject:
and copy
increase the retain count.
Try [array addObject:[[dictionary copy] autorelease]]
Upvotes: 4