I have created a class which has instance variables that are other classes that I generated, so I have:
class1.h:
Code:
@interface class1 : NSObject {
class2 *var2;
}
@property (nonatomic, retain) class2 *var2;
When I allocate and then release a class1 variable, it creates but then does not release var2 and I get a memory leak. However, if I use an NSString instance variable rather than a class2 instance variable, I don't get a memory leak...
Is this how Objective C is supposed to work? Is there some way I can make my class2 behave in a similar manner to NSString?
(I've got rid of the leak by adding [var2 release] to the class1 release method, and [var2 retain] to the class1 retain method... but I feel like I'm missing something else...??)
Thanks for any insight
Mike