Re: Memory Management
Re: Memory Management
- Subject: Re: Memory Management
- From: "Mike Vannorsdel" <email@hidden>
- Date: Sun, 5 Aug 2001 15:58:37 -0600
True. If you're not sure if your superclass's init method is
implemented or returns anything, definitely test for nil.
On Sunday, August 5, 2001, at 03:10 PM, Ondra Cada wrote:
Mike,
Mike Vannorsdel (MV) wrote at Sun, 5 Aug 2001 14:41:29 -0600:
MV> self = [super init]; //initialize the object using the super
...
MV> self = [super initWithFrame: frameRect];
Actually, it is better to get used to the generic pattern of
-init... {
if ((self=[super init...])!=nil) {
...
}
return self;
}
Someone higher on the inheritance tree might have used something like
-init... {
...
if (there-is-no-sense-in-making-this-object) {
[self autorelease];
return nil;
}
...
}
or even
-init... {
...
if (so-long-Dr-Jekyll) {
[self autorelease];
return [[Hyde alloc] init...];
}
...
}
If it happens to be so, your init would not work properly.