When writing an abstract class, or a class that doesn't get instantiated directly... do you tend to write a dealloc method in the abstract class and release where appropriate, and then allow for children to call [super dealloc] and then worry about only instance variables they add which aren't part of the super class?
How do you folks manage memory with abstract classes?
I'm thinking something along the lines of:
@interface ClassA : NSObject {
NSArray *foo;
}
@end
@implementation ClassA
- (void) dealloc {
[foo release];
[super dealloc];
}
@end
@interface ClassB : ClassA {
NSArray *bar;
}
@end
@implementation ClassB
- (void) dealloc {
[bar release];
[super dealloc];
}
@end
Please pardon any syntactical errors, I just wrote this up on the fly. Does the above make sense or should memory be managed differently? GC isn't an option as I'm doing this on the iPhone.