• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Memory Management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Memory Management
      • From: Nat! <email@hidden>
  • Prev by Date: Re: Memory Management
  • Next by Date: Byte Twiddling and Altivec
  • Previous by thread: Re: Memory Management
  • Next by thread: Re: Memory Management
  • Index(es):
    • Date
    • Thread