Yes!....wait....No!.....wait......what?![]()
Actually, your post is the most confusing post in this thread...I'm just as confused by you by this post![]()
No, alloc and release do not always occur in the same function. For example, one object creates another object (and stores a pointer to it) at init time...then at dealloc time, releases it. Very common.
@interface Car : NSObject {
Wheel *wheel_;
}
@end
@implementation Car
- (id)init {
if((self = [super init])) {
wheel_ = [[Wheel alloc] init];
}
return self;
}
- (void)dealloc {
[wheel_ release];
[super dealloc];
}
@end
- (void)setWheel(Wheel *aWheel) {
if(aWheel != wheel_) {
[wheel_ release];
wheel_ = [aWheel retain];
}
}