@interface Approval : NSObject
{
NSMutableArray *approvalValues;
}
@property (nonatomic,retain) NSMutableArray *approvalValues;
If i do this, do I still need to call `approvalValues = [[NSMutableArray alloc] init] in the init method? I was under the impression that I had to but it is causing a leak. In the dealloc method I am releasing approvalValues
You need to
allocandinitapprovalValues. The problem seems to be related to the fact that you are over-retaining your object.Your code probably looks like this:
allocwill return an object with aretainCountof 1, and when using theretainsetter it will get bumped to 2. In order to solve it, you might want toautoreleasethe object before assigning it, making a code that looks like this:This will end up with an instance variable with a
retainCountof only 1, so when youdeallocthe object it won’t leak.