This is why you should use properties or explicit accessors.
If you had this:
@interface myObject : NSObject
{
NSMutableArray *classMembers;
}
@property(nonatomic, retain) NSMutableArray *classMembers;
@end
@implementation myObject
@synthesize classMembers;
-(id) init{
if (self=[super init]) {
self.classMembers=[[NSMutableArray alloc] initWithCapacity:1];
}
return self;
}//-------------------------------------(id) init------------------------------------
-(void) dealloc{
[classMembers release];
[super dealloc];
}//-------------------------------------(void) dealloc------------------------------------
@end
You would not (and should not ever) have to miss around with the retention of a property. This eliminates all leaks and over-releasing of properties.
If the property's object leaks, then you know automatically it is being retained in another object other than the instance of the class containing the property.